You are here

public function AbstractValidatorTest::testRecursiveArrayTraversalCannotBeDisabled in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php, line 626

Class

AbstractValidatorTest
@since 2.5 @author Bernhard Schussek <bschussek@gmail.com>

Namespace

Symfony\Component\Validator\Tests\Validator

Code

public function testRecursiveArrayTraversalCannotBeDisabled() {
  $entity = new Entity();
  $entity->reference = array(
    2 => 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);
}