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