public function Abstract2Dot5ApiTest::testReferenceTraversalDisabledOnReferenceEnabledOnClass in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Tests/Validator/Abstract2Dot5ApiTest.php \Symfony\Component\Validator\Tests\Validator\Abstract2Dot5ApiTest::testReferenceTraversalDisabledOnReferenceEnabledOnClass()
File
- vendor/
symfony/ validator/ Tests/ Validator/ Abstract2Dot5ApiTest.php, line 488
Class
- Abstract2Dot5ApiTest
- Verifies that a validator satisfies the API of Symfony 2.5+.
Namespace
Symfony\Component\Validator\Tests\ValidatorCode
public function testReferenceTraversalDisabledOnReferenceEnabledOnClass() {
$test = $this;
$entity = new Entity();
$entity->reference = new \ArrayIterator(array(
'key' => new Reference(),
));
$callback = function ($value, ExecutionContextInterface $context) use ($test) {
$test
->fail('Should not be called');
};
$traversableMetadata = new ClassMetadata('ArrayIterator');
$traversableMetadata
->addConstraint(new Traverse(true));
$this->metadataFactory
->addMetadata($traversableMetadata);
$this->referenceMetadata
->addConstraint(new Callback(array(
'callback' => $callback,
'groups' => 'Group',
)));
$this->metadata
->addPropertyConstraint('reference', new Valid(array(
'traverse' => false,
)));
$violations = $this
->validate($entity, new Valid(), 'Group');
/* @var ConstraintViolationInterface[] $violations */
$this
->assertCount(0, $violations);
}