public function AbstractValidatorTest::testReplaceDefaultGroupByGroupSequenceArray in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Tests/Validator/AbstractValidatorTest.php \Symfony\Component\Validator\Tests\Validator\AbstractValidatorTest::testReplaceDefaultGroupByGroupSequenceArray()
File
- vendor/
symfony/ validator/ Tests/ Validator/ AbstractValidatorTest.php, line 1118
Class
- AbstractValidatorTest
- @since 2.5
Namespace
Symfony\Component\Validator\Tests\ValidatorCode
public function testReplaceDefaultGroupByGroupSequenceArray() {
$entity = new Entity();
$callback1 = function ($value, ExecutionContextInterface $context) {
$context
->addViolation('Violation in Group 2');
};
$callback2 = function ($value, ExecutionContextInterface $context) {
$context
->addViolation('Violation in Group 3');
};
$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 = array(
'Group 1',
'Group 2',
'Group 3',
'Entity',
);
$this->metadata
->setGroupSequence($sequence);
$violations = $this
->validate($entity, null, 'Default');
/* @var ConstraintViolationInterface[] $violations */
$this
->assertCount(1, $violations);
$this
->assertSame('Violation in Group 2', $violations[0]
->getMessage());
}