@@ -45,12 +45,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
4545
4646 protected function setUp ()
4747 {
48- $ this ->dispatcher = $ this ->getMock ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' );
49- $ this ->factory = $ this ->getMock ('Symfony\Component\Form\FormFactoryInterface ' );
50- $ this ->serverParams = $ this ->getMock (
51- 'Symfony\Component\Form\Extension\Validator\Util\ServerParams ' ,
52- array ('getNormalizedIniPostMaxSize ' , 'getContentLength ' )
53- );
48+ $ this ->dispatcher = $ this ->getMockBuilder ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' )->getMock ();
49+ $ this ->factory = $ this ->getMockBuilder ('Symfony\Component\Form\FormFactoryInterface ' )->getMock ();
50+ $ this ->serverParams = $ this ->getMockBuilder ('Symfony\Component\Form\Extension\Validator\Util\ServerParams ' )->setMethods (array ('getNormalizedIniPostMaxSize ' , 'getContentLength ' ))->getMock ();
5451
5552 parent ::setUp ();
5653 }
@@ -62,7 +59,7 @@ protected function createValidator()
6259
6360 public function testValidate ()
6461 {
65- $ object = $ this ->getMock ('\stdClass ' );
62+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
6663 $ options = array ('validation_groups ' => array ('group1 ' , 'group2 ' ));
6764 $ form = $ this ->getBuilder ('name ' , '\stdClass ' , $ options )
6865 ->setData ($ object )
@@ -78,7 +75,7 @@ public function testValidate()
7875
7976 public function testValidateConstraints ()
8077 {
81- $ object = $ this ->getMock ('\stdClass ' );
78+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
8279 $ constraint1 = new NotNull (array ('groups ' => array ('group1 ' , 'group2 ' )));
8380 $ constraint2 = new NotBlank (array ('groups ' => 'group2 ' ));
8481
@@ -105,7 +102,7 @@ public function testValidateConstraints()
105102
106103 public function testValidateChildIfValidConstraint ()
107104 {
108- $ object = $ this ->getMock ('\stdClass ' );
105+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
109106
110107 $ parent = $ this ->getBuilder ('parent ' )
111108 ->setCompound (true )
@@ -129,7 +126,7 @@ public function testValidateChildIfValidConstraint()
129126
130127 public function testDontValidateIfParentWithoutValidConstraint ()
131128 {
132- $ object = $ this ->getMock ('\stdClass ' );
129+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
133130
134131 $ parent = $ this ->getBuilder ('parent ' , null )
135132 ->setCompound (true )
@@ -163,7 +160,7 @@ public function testMissingConstraintIndex()
163160
164161 public function testValidateConstraintsOptionEvenIfNoValidConstraint ()
165162 {
166- $ object = $ this ->getMock ('\stdClass ' );
163+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
167164 $ constraint1 = new NotNull (array ('groups ' => array ('group1 ' , 'group2 ' )));
168165 $ constraint2 = new NotBlank (array ('groups ' => 'group2 ' ));
169166
@@ -190,7 +187,7 @@ public function testValidateConstraintsOptionEvenIfNoValidConstraint()
190187
191188 public function testDontValidateIfNoValidationGroups ()
192189 {
193- $ object = $ this ->getMock ('\stdClass ' );
190+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
194191
195192 $ form = $ this ->getBuilder ('name ' , '\stdClass ' , array (
196193 'validation_groups ' => array (),
@@ -209,9 +206,9 @@ public function testDontValidateIfNoValidationGroups()
209206
210207 public function testDontValidateConstraintsIfNoValidationGroups ()
211208 {
212- $ object = $ this ->getMock ('\stdClass ' );
213- $ constraint1 = $ this ->getMock ('Symfony\Component\Validator\Constraint ' );
214- $ constraint2 = $ this ->getMock ('Symfony\Component\Validator\Constraint ' );
209+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
210+ $ constraint1 = $ this ->getMockBuilder ('Symfony\Component\Validator\Constraint ' )-> getMock ( );
211+ $ constraint2 = $ this ->getMockBuilder ('Symfony\Component\Validator\Constraint ' )-> getMock ( );
215212
216213 $ options = array (
217214 'validation_groups ' => array (),
@@ -233,7 +230,7 @@ public function testDontValidateConstraintsIfNoValidationGroups()
233230
234231 public function testDontValidateIfNotSynchronized ()
235232 {
236- $ object = $ this ->getMock ('\stdClass ' );
233+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
237234
238235 $ form = $ this ->getBuilder ('name ' , '\stdClass ' , array (
239236 'invalid_message ' => 'invalid_message_key ' ,
@@ -267,7 +264,7 @@ function () { throw new TransformationFailedException(); }
267264
268265 public function testAddInvalidErrorEvenIfNoValidationGroups ()
269266 {
270- $ object = $ this ->getMock ('\stdClass ' );
267+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
271268
272269 $ form = $ this ->getBuilder ('name ' , '\stdClass ' , array (
273270 'invalid_message ' => 'invalid_message_key ' ,
@@ -302,9 +299,9 @@ function () { throw new TransformationFailedException(); }
302299
303300 public function testDontValidateConstraintsIfNotSynchronized ()
304301 {
305- $ object = $ this ->getMock ('\stdClass ' );
306- $ constraint1 = $ this ->getMock ('Symfony\Component\Validator\Constraint ' );
307- $ constraint2 = $ this ->getMock ('Symfony\Component\Validator\Constraint ' );
302+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
303+ $ constraint1 = $ this ->getMockBuilder ('Symfony\Component\Validator\Constraint ' )-> getMock ( );
304+ $ constraint2 = $ this ->getMockBuilder ('Symfony\Component\Validator\Constraint ' )-> getMock ( );
308305
309306 $ options = array (
310307 'invalid_message ' => 'invalid_message_key ' ,
@@ -337,7 +334,7 @@ function () { throw new TransformationFailedException(); }
337334 // https://github.com/symfony/symfony/issues/4359
338335 public function testDontMarkInvalidIfAnyChildIsNotSynchronized ()
339336 {
340- $ object = $ this ->getMock ('\stdClass ' );
337+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
341338
342339 $ failingTransformer = new CallbackTransformer (
343340 function ($ data ) { return $ data ; },
@@ -367,7 +364,7 @@ function () { throw new TransformationFailedException(); }
367364
368365 public function testHandleCallbackValidationGroups ()
369366 {
370- $ object = $ this ->getMock ('\stdClass ' );
367+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
371368 $ options = array ('validation_groups ' => array ($ this , 'getValidationGroups ' ));
372369 $ form = $ this ->getBuilder ('name ' , '\stdClass ' , $ options )
373370 ->setData ($ object )
@@ -383,7 +380,7 @@ public function testHandleCallbackValidationGroups()
383380
384381 public function testDontExecuteFunctionNames ()
385382 {
386- $ object = $ this ->getMock ('\stdClass ' );
383+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
387384 $ options = array ('validation_groups ' => 'header ' );
388385 $ form = $ this ->getBuilder ('name ' , '\stdClass ' , $ options )
389386 ->setData ($ object )
@@ -398,7 +395,7 @@ public function testDontExecuteFunctionNames()
398395
399396 public function testHandleClosureValidationGroups ()
400397 {
401- $ object = $ this ->getMock ('\stdClass ' );
398+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
402399 $ options = array ('validation_groups ' => function (FormInterface $ form ) {
403400 return array ('group1 ' , 'group2 ' );
404401 });
@@ -416,7 +413,7 @@ public function testHandleClosureValidationGroups()
416413
417414 public function testUseValidationGroupOfClickedButton ()
418415 {
419- $ object = $ this ->getMock ('\stdClass ' );
416+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
420417
421418 $ parent = $ this ->getBuilder ('parent ' )
422419 ->setCompound (true )
@@ -443,7 +440,7 @@ public function testUseValidationGroupOfClickedButton()
443440
444441 public function testDontUseValidationGroupOfUnclickedButton ()
445442 {
446- $ object = $ this ->getMock ('\stdClass ' );
443+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
447444
448445 $ parent = $ this ->getBuilder ('parent ' )
449446 ->setCompound (true )
@@ -470,7 +467,7 @@ public function testDontUseValidationGroupOfUnclickedButton()
470467
471468 public function testUseInheritedValidationGroup ()
472469 {
473- $ object = $ this ->getMock ('\stdClass ' );
470+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
474471
475472 $ parentOptions = array ('validation_groups ' => 'group ' );
476473 $ parent = $ this ->getBuilder ('parent ' , null , $ parentOptions )
@@ -492,7 +489,7 @@ public function testUseInheritedValidationGroup()
492489
493490 public function testUseInheritedCallbackValidationGroup ()
494491 {
495- $ object = $ this ->getMock ('\stdClass ' );
492+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
496493
497494 $ parentOptions = array ('validation_groups ' => array ($ this , 'getValidationGroups ' ));
498495 $ parent = $ this ->getBuilder ('parent ' , null , $ parentOptions )
@@ -514,7 +511,7 @@ public function testUseInheritedCallbackValidationGroup()
514511
515512 public function testUseInheritedClosureValidationGroup ()
516513 {
517- $ object = $ this ->getMock ('\stdClass ' );
514+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
518515
519516 $ parentOptions = array (
520517 'validation_groups ' => function (FormInterface $ form ) {
@@ -540,7 +537,7 @@ public function testUseInheritedClosureValidationGroup()
540537
541538 public function testAppendPropertyPath ()
542539 {
543- $ object = $ this ->getMock ('\stdClass ' );
540+ $ object = $ this ->getMockBuilder ('\stdClass ' )-> getMock ( );
544541 $ form = $ this ->getBuilder ('name ' , '\stdClass ' )
545542 ->setData ($ object )
546543 ->getForm ();
@@ -618,9 +615,9 @@ public function getValidationGroups(FormInterface $form)
618615
619616 private function getMockExecutionContext ()
620617 {
621- $ context = $ this ->getMock ('Symfony\Component\Validator\Context\ExecutionContextInterface ' );
622- $ validator = $ this ->getMock ('Symfony\Component\Validator\Validator\ValidatorInterface ' );
623- $ contextualValidator = $ this ->getMock ('Symfony\Component\Validator\Validator\ContextualValidatorInterface ' );
618+ $ context = $ this ->getMockBuilder ('Symfony\Component\Validator\Context\ExecutionContextInterface ' )-> getMock ( );
619+ $ validator = $ this ->getMockBuilder ('Symfony\Component\Validator\Validator\ValidatorInterface ' )-> getMock ( );
620+ $ contextualValidator = $ this ->getMockBuilder ('Symfony\Component\Validator\Validator\ContextualValidatorInterface ' )-> getMock ( );
624621
625622 $ validator ->expects ($ this ->any ())
626623 ->method ('inContext ' )
@@ -668,6 +665,6 @@ private function getSubmitButton($name = 'name', array $options = array())
668665 */
669666 private function getDataMapper ()
670667 {
671- return $ this ->getMock ('Symfony\Component\Form\DataMapperInterface ' );
668+ return $ this ->getMockBuilder ('Symfony\Component\Form\DataMapperInterface ' )-> getMock ( );
672669 }
673670}
0 commit comments