19
19
use Symfony \Component \Form \Extension \Validator \Constraints \FormValidator ;
20
20
use Symfony \Component \Form \Util \PropertyPath ;
21
21
use Symfony \Component \Validator \Constraint ;
22
+ use Symfony \Component \Validator \Constraints \NotNull ;
23
+ use Symfony \Component \Validator \Constraints \NotBlank ;
22
24
use Symfony \Component \Validator \GlobalExecutionContext ;
23
25
use Symfony \Component \Validator \ExecutionContext ;
24
26
@@ -88,8 +90,8 @@ public function testValidateConstraints()
88
90
$ context = $ this ->getExecutionContext ();
89
91
$ graphWalker = $ context ->getGraphWalker ();
90
92
$ object = $ this ->getMock ('\stdClass ' );
91
- $ constraint1 = $ this -> getMock ( ' Symfony\Component\Validator\Constraint ' );
92
- $ constraint2 = $ this -> getMock ( ' Symfony\Component\Validator\Constraint ' );
93
+ $ constraint1 = new NotNull ( array ( ' groups ' => array ( ' group1 ' , ' group2 ' )) );
94
+ $ constraint2 = new NotBlank ( array ( ' groups ' => ' group2 ' ) );
93
95
94
96
$ options = array (
95
97
'validation_groups ' => array ('group1 ' , 'group2 ' ),
@@ -112,12 +114,6 @@ public function testValidateConstraints()
112
114
->method ('walkConstraint ' )
113
115
->with ($ constraint1 , $ object , 'group1 ' , 'data ' );
114
116
$ graphWalker ->expects ($ this ->at (3 ))
115
- ->method ('walkConstraint ' )
116
- ->with ($ constraint1 , $ object , 'group2 ' , 'data ' );
117
- $ graphWalker ->expects ($ this ->at (4 ))
118
- ->method ('walkConstraint ' )
119
- ->with ($ constraint2 , $ object , 'group1 ' , 'data ' );
120
- $ graphWalker ->expects ($ this ->at (5 ))
121
117
->method ('walkConstraint ' )
122
118
->with ($ constraint2 , $ object , 'group2 ' , 'data ' );
123
119
@@ -153,8 +149,8 @@ public function testValidateConstraintsEvenIfNoCascadeValidation()
153
149
$ context = $ this ->getExecutionContext ();
154
150
$ graphWalker = $ context ->getGraphWalker ();
155
151
$ object = $ this ->get
B435
Mock ('\stdClass ' );
156
- $ constraint1 = $ this -> getMock ( ' Symfony\Component\Validator\Constraint ' );
157
- $ constraint2 = $ this -> getMock ( ' Symfony\Component\Validator\Constraint ' );
152
+ $ constraint1 = new NotNull ( array ( ' groups ' => array ( ' group1 ' , ' group2 ' )) );
153
+ $ constraint2 = new NotBlank ( array ( ' groups ' => ' group2 ' ) );
158
154
159
155
$ parent = $ this ->getBuilder ('parent ' , null , array ('cascade_validation ' => false ))
160
156
->setCompound (true )
@@ -173,12 +169,6 @@ public function testValidateConstraintsEvenIfNoCascadeValidation()
173
169
->method ('walkConstraint ' )
174
170
->with ($ constraint1 , $ object , 'group1 ' , 'data ' );
175
171
$ graphWalker ->expects ($ this ->at (1 ))
176
- ->method ('walkConstraint ' )
177
- ->with ($ constraint1 , $ object , 'group2 ' , 'data ' );
178
- $ graphWalker ->expects ($ this ->at (2 ))
179
- ->method ('walkConstraint ' )
180
- ->with ($ constraint2 , $ object , 'group1 ' , 'data ' );
181
- $ graphWalker ->expects ($ this ->at (3 ))
182
172
->method ('walkConstraint ' )
183
173
->with ($ constraint2 , $ object , 'group2 ' , 'data ' );
184
174
0 commit comments