$violations =
$this->validator->
validate($entity, null,
['one', 'two'
]);
$this->
assertCount(2,
$violations);
$this->
assertInstanceOf(Length::
class,
$violations->
get(0
)->
getConstraint());
$this->
assertInstanceOf(NotBlank::
class,
$violations->
get(1
)->
getConstraint());
} public function testGroupedMethodConstraintValidateInSequence() { $metadata =
new ClassMetadata(EntityWithGroupedConstraintOnMethods::
class);
$metadata->
addPropertyConstraint('bar',
new NotNull(['groups' => 'Foo'
]));
$metadata->
addGetterMethodConstraint('validInFoo', 'isValidInFoo',
new IsTrue(['groups' => 'Foo'
]));
$metadata->
addGetterMethodConstraint('bar', 'getBar',
new NotNull(['groups' => 'Bar'
]));
$this->metadataFactory->
addMetadata($metadata);
$entity =
new EntityWithGroupedConstraintOnMethods();
$groups =
new GroupSequence(['EntityWithGroupedConstraintOnMethods', 'Foo', 'Bar'
]);
$violations =
$this->validator->
validate($entity, null,
$groups);
$this->
assertCount(2,
$violations);
$this->
assertInstanceOf(NotNull::
class,
$violations->
get(0
)->
getConstraint());