File tree 1 file changed +8
-17
lines changed
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::
182
182
namespace Tests\AppBundle\Form\Type;
183
183
184
184
// ...
185
- use AppBundle\Form\Type\TestedType;
186
185
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;
191
187
192
188
class TestedTypeTest extends TypeTestCase
193
189
{
194
- private $validator;
195
-
196
190
protected function getExtensions()
197
191
{
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();
207
198
208
199
return [
209
- new ValidatorExtension($this-> validator),
200
+ new ValidatorExtension($validator),
210
201
];
211
202
}
212
203
You can’t perform that action at this time.
0 commit comments