You are here

public function AbstractValidatorTest::testArrayTraversalCannotBeDisabled in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Tests/Validator/AbstractValidatorTest.php \Symfony\Component\Validator\Tests\Validator\AbstractValidatorTest::testArrayTraversalCannotBeDisabled()

File

vendor/symfony/validator/Tests/Validator/AbstractValidatorTest.php, line 607

Class

AbstractValidatorTest
@since 2.5

Namespace

Symfony\Component\Validator\Tests\Validator

Code

public function testArrayTraversalCannotBeDisabled() {
  $entity = new Entity();
  $entity->reference = array(
    'key' => new Reference(),
  );
  $callback = function ($value, ExecutionContextInterface $context) {
    $context
      ->addViolation('Message %param%', array(
      '%param%' => 'value',
    ));
  };
  $this->metadata
    ->addPropertyConstraint('reference', new Valid(array(
    'traverse' => false,
  )));
  $this->referenceMetadata
    ->addConstraint(new Callback($callback));
  $violations = $this
    ->validate($entity);

  /* @var ConstraintViolationInterface[] $violations */
  $this
    ->assertCount(1, $violations);
}