File tree Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -182,31 +182,22 @@ allows you to return a list of extensions to register::
182182 namespace Tests\AppBundle\Form\Type;
183183
184184 // ...
185- use AppBundle\Form\Type\TestedType;
186185 use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
187- use Symfony\Component\Form\Form;
188- use Symfony\Component\Validator\ConstraintViolationList;
189- use Symfony\Component\Validator\Mapping\ClassMetadata;
190- use Symfony\Component\Validator\Validator\ValidatorInterface;
186+ use Symfony\Component\Validator\Validation;
191187
192188 class TestedTypeTest extends TypeTestCase
193189 {
194- private $validator;
195-
196190 protected function getExtensions()
197191 {
198- $this->validator = $this->createMock(ValidatorInterface::class);
199- // use getMock() on PHPUnit 5.3 or below
200- // $this->validator = $this->getMock(ValidatorInterface::class);
201- $this->validator
202- ->method('validate')
203- ->will($this->returnValue(new ConstraintViolationList()));
204- $this->validator
205- ->method('getMetadataFor')
206- ->will($this->returnValue(new ClassMetadata(Form::class)));
192+ $validator = Validation::createValidator();
193+
194+ // or if you also need to read constraints from annotations
195+ $validator = Validation::createValidatorBuilder()
196+ ->enableAnnotationMapping()
197+ ->getValidator();
207198
208199 return [
209- new ValidatorExtension($this-> validator),
200+ new ValidatorExtension($validator),
210201 ];
211202 }
212203
You can’t perform that action at this time.
0 commit comments