public function LegacyExecutionContextTest::testGetPropertyPathWithNestedCollectionsAndAllMixed in Plug 7
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ LegacyExecutionContextTest.php, line 286
Class
- LegacyExecutionContextTest
- @group legacy
Namespace
Symfony\Component\Validator\TestsCode
public function testGetPropertyPathWithNestedCollectionsAndAllMixed() {
$constraints = new Collection(array(
'shelves' => new All(array(
'constraints' => array(
new Collection(array(
'name' => new ConstraintA(),
'books' => new All(array(
'constraints' => array(
new ConstraintA(),
),
)),
)),
),
)),
'name' => new ConstraintA(),
));
$data = array(
'shelves' => array(
array(
'name' => 'Research',
'books' => array(
'foo',
'bar',
),
),
array(
'name' => 'VALID',
'books' => array(
'foozy',
'VALID',
'bazzy',
),
),
),
'name' => 'Library',
);
$expectedViolationPaths = array(
'[shelves][0][name]',
'[shelves][0][books][0]',
'[shelves][0][books][1]',
'[shelves][1][books][0]',
'[shelves][1][books][2]',
'[name]',
);
$visitor = new ValidationVisitor('Root', $this->metadataFactory, new ConstraintValidatorFactory(), $this->translator);
$context = new ExecutionContext($visitor, $this->translator, self::TRANS_DOMAIN);
$context
->validateValue($data, $constraints);
foreach ($context
->getViolations() as $violation) {
$violationPaths[] = $violation
->getPropertyPath();
}
$this
->assertEquals($expectedViolationPaths, $violationPaths);
}