@@ -50,21 +50,11 @@ protected function setUp()
5050 $ this ->validator = $ this ->createValidator ($ this ->metadataFactory );
5151 }
5252
53- protected function validate ($ value , $ constraints , $ groups = null )
53+ protected function validate ($ value , $ constraints = null , $ groups = null )
5454 {
5555 return $ this ->validator ->validate ($ value , $ constraints , $ groups );
5656 }
5757
58- protected function validateObject ($ object , $ groups = null )
59- {
60- return $ this ->validator ->validateObject ($ object , $ groups );
61- }
62-
63- protected function validateObjects ($ objects , $ groups = null , $ deep = false )
64- {
65- return $ this ->validator ->validateObjects ($ objects , $ groups , $ deep );
66- }
67-
6858 protected function validateProperty ($ object , $ propertyName , $ groups = null )
6959 {
7060 return $ this ->validator ->validateProperty ($ object , $ propertyName , $ groups );
@@ -88,7 +78,7 @@ public function testNoDuplicateValidationIfConstraintInMultipleGroups()
8878 'groups ' => array ('Group 1 ' , 'Group 2 ' ),
8979 )));
9080
91- $ violations = $ this ->validator ->validateObject ($ entity , array ('Group 1 ' , 'Group 2 ' ));
81+ $ violations = $ this ->validator ->validate ($ entity, new Valid () , array ('Group 1 ' , 'Group 2 ' ));
9282
9383 /** @var ConstraintViolationInterface[] $violations */
9484 $ this ->assertCount (1 , $ violations );
@@ -119,7 +109,7 @@ public function testGroupSequenceAbortsAfterFailedGroup()
119109 )));
120110
121111 $ sequence = new GroupSequence (array ('Group 1 ' , 'Group 2 ' , 'Group 3 ' ));
122- $ violations = $ this ->validator ->validateObject ($ entity , $ sequence );
112+ $ violations = $ this ->validator ->validate ($ entity, new Valid () , $ sequence );
123113
124114 /** @var ConstraintViolationInterface[] $violations */
125115 $ this ->assertCount (1 , $ violations );
@@ -149,7 +139,7 @@ public function testGroupSequenceIncludesReferences()
149139 )));
150140
151141 $ sequence = new GroupSequence (array ('Group 1 ' , 'Entity ' ));
152- $ violations = $ this ->validator ->validateObject ($ entity , $ sequence );
142+ $ violations = $ this ->validator ->validate ($ entity, new Valid () , $ sequence );
153143
154144 /** @var ConstraintViolationInterface[] $violations */
155145 $ this ->assertCount (1 , $ violations );
@@ -167,7 +157,7 @@ public function testValidateInSeparateContext()
167157 ->getValidator ()
168158 // Since the validator is not context aware, the group must
169159 // be passed explicitly
170- ->validateObject ($ value ->reference , 'Group ' )
160+ ->validate ($ value ->reference , new Valid () , 'Group ' )
171161 ;
172162
173163 /** @var ConstraintViolationInterface[] $violations */
@@ -208,7 +198,7 @@ public function testValidateInSeparateContext()
208198 'groups ' => 'Group ' ,
209199 )));
210200
211- $ violations = $ this ->validator ->validateObject ($ entity , 'Group ' );
201+ $ violations = $ this ->validator ->validate ($ entity, new Valid () , 'Group ' );
212202
213203 /** @var ConstraintViolationInterface[] $violations */
214204 $ this ->assertCount (1 , $ violations );
@@ -226,7 +216,7 @@ public function testValidateInContext()
226216 ->getValidator ()
227217 ->inContext ($ context )
228218 ->atPath ('subpath ' )
229- ->validateObject ($ value ->reference )
219+ ->validate ($ value ->reference )
230220 ;
231221 };
232222
@@ -252,7 +242,7 @@ public function testValidateInContext()
252242 'groups ' => 'Group ' ,
253243 )));
254244
255- $ violations = $ this ->validator ->validateObject ($ entity , 'Group ' );
245+ $ violations = $ this ->validator ->validate ($ entity, new Valid () , 'Group ' );
256246
257247 /** @var ConstraintViolationInterface[] $violations */
258248 $ this ->assertCount (1 , $ violations );
@@ -277,7 +267,7 @@ public function testValidateArrayInContext()
277267 ->getValidator ()
278268 ->inContext ($ context )
279269 ->atPath ('subpath ' )
280- ->validateObjects (array ('key ' => $ value ->reference ))
270+ ->validate (array ('key ' => $ value ->reference ))
281271 ;
282272 };
283273
@@ -303,7 +293,7 @@ public function testValidateArrayInContext()
303293 'groups ' => 'Group ' ,
304294 )));
305295
306- $ violations = $ this ->validator ->validateObject ($ entity , 'Group ' );
296+ $ violations = $ this ->validator ->validate ($ entity, new Valid () , 'Group ' );
307297
308298 /** @var ConstraintViolationInterface[] $violations */
309299 $ this ->assertCount (1 , $ violations );
@@ -317,44 +307,6 @@ public function testValidateArrayInContext()
317307 $ this ->assertNull ($ violations [0 ]->getCode ());
318308 }
319309
320- public function testValidateAcceptsValid ()
321- {
322- $ test = $ this ;
323- $ entity = new Entity ();
324-
325- $ callback = function ($ value , ExecutionContextInterface $ context ) use ($ test , $ entity ) {
326- $ test ->assertSame ($ test ::ENTITY_CLASS , $ context ->getClassName ());
327- $ test ->assertNull ($ context ->getPropertyName ());
328- $ test ->assertSame ('' , $ context ->getPropertyPath ());
329- $ test ->assertSame ('Group ' , $ context ->getGroup ());
330- $ test ->assertSame ($ test ->metadata , $ context ->getMetadata ());
331- $ test ->assertSame ($ entity , $ context ->getRoot ());
332- $ test ->assertSame ($ entity , $ context ->getValue ());
333- $ test ->assertSame ($ entity , $ value );
334-
335- $ context ->addViolation ('Message %param% ' , array ('%param% ' => 'value ' ));
336- };
337-
338- $ this ->metadata ->addConstraint (new Callback (array (
339- 'callback ' => $ callback ,
340- 'groups ' => 'Group ' ,
341- )));
342-
343- // This is the same as when calling validateObject()
344- $ violations = $ this ->validator ->validate ($ entity , new Valid (), 'Group ' );
345-
346- /** @var ConstraintViolationInterface[] $violations */
347- $ this ->assertCount (1 , $ violations );
348- $ this ->assertSame ('Message value ' , $ violations [0 ]->getMessage ());
349- $ this ->assertSame ('Message %param% ' , $ violations [0 ]->getMessageTemplate ());
350- $ this ->assertSame (array ('%param% ' => 'value ' ), $ violations [0 ]->getMessageParameters ());
351- $ this ->assertSame ('' , $ violations [0 ]->getPropertyPath ());
352- $ this ->assertSame ($ entity , $ violations [0 ]->getRoot ());
353- $ this ->assertSame ($ entity , $ violations [0 ]->getInvalidValue ());
354- $ this ->assertNull ($ violations [0 ]->getMessagePluralization ());
355- $ this ->assertNull ($ violations [0 ]->getCode ());
356- }
357-
358310 public function testTraverseTraversableByDefault ()
359311 {
360312 $ test = $ this ;
@@ -380,7 +332,7 @@ public function testTraverseTraversableByDefault()
380332 'groups ' => 'Group ' ,
381333 )));
382334
383- $ violations = $ this ->validateObject ($ traversable , 'Group ' );
335+ $ violations = $ this ->validate ($ traversable, new Valid () , 'Group ' );
384336
385337 /** @var ConstraintViolationInterface[] $violations */
386338 $ this ->assertCount (1 , $ violations );
@@ -403,7 +355,7 @@ public function testExpectTraversableIfTraverseOnClass()
403355
404356 $ this ->metadata ->addConstraint (new Traverse ());
405357
406- $ this ->validator ->validateObject ($ entity );
358+ $ this ->validator ->validate ($ entity );
407359 }
408360
409361 public function testAddCustomizedViolation ()
@@ -421,7 +373,7 @@ public function testAddCustomizedViolation()
421373
422374 $ this ->metadata ->addConstraint (new Callback ($ callback ));
423375
424- $ violations = $ this ->validator ->validateObject ($ entity );
376+ $ violations = $ this ->validator ->validate ($ entity );
425377
426378 /** @var ConstraintViolationInterface[] $violations */
427379 $ this ->assertCount (1 , $ violations );
0 commit comments