public function Abstract2Dot5ApiTest::testGroupSequenceIncludesReferences in Plug 7
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ Validator/ Abstract2Dot5ApiTest.php, line 110
Class
- Abstract2Dot5ApiTest
- Verifies that a validator satisfies the API of Symfony 2.5+.
Namespace
Symfony\Component\Validator\Tests\ValidatorCode
public function testGroupSequenceIncludesReferences() {
$entity = new Entity();
$entity->reference = new Reference();
$callback1 = function ($value, ExecutionContextInterface $context) {
$context
->addViolation('Reference violation 1');
};
$callback2 = function ($value, ExecutionContextInterface $context) {
$context
->addViolation('Reference violation 2');
};
$this->metadata
->addPropertyConstraint('reference', new Valid());
$this->referenceMetadata
->addConstraint(new Callback(array(
'callback' => $callback1,
'groups' => 'Group 1',
)));
$this->referenceMetadata
->addConstraint(new Callback(array(
'callback' => $callback2,
'groups' => 'Group 2',
)));
$sequence = new GroupSequence(array(
'Group 1',
'Entity',
));
$violations = $this->validator
->validate($entity, new Valid(), $sequence);
/** @var ConstraintViolationInterface[] $violations */
$this
->assertCount(1, $violations);
$this
->assertSame('Reference violation 1', $violations[0]
->getMessage());
}