diff --git a/cookbook/form/unit_testing.rst b/cookbook/form/unit_testing.rst index 7a9100fda29..944ed25b372 100644 --- a/cookbook/form/unit_testing.rst +++ b/cookbook/form/unit_testing.rst @@ -177,18 +177,22 @@ on other extensions. You need add those extensions to the factory object:: use Symfony\Component\Form\Forms; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension; + use Symfony\Component\Validator\ConstraintViolationList; class TestedTypeTest extends TypeTestCase { protected function setUp() { parent::setUp(); + + $validator = $this->getMock('\Symfony\Component\Validator\ValidatorInterface'); + $validator->method('validate')->will($this->returnValue(new ConstraintViolationList())); $this->factory = Forms::createFormFactoryBuilder() ->addExtensions($this->getExtensions()) ->addTypeExtension( new FormTypeValidatorExtension( - $this->getMock('Symfony\Component\Validator\ValidatorInterface') + $validator ) ) ->addTypeGuesser(
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: