You are here

public function Abstract2Dot5ApiTest::testTraversalDisabledOnClass in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php, line 390

Class

Abstract2Dot5ApiTest
Verifies that a validator satisfies the API of Symfony 2.5+.

Namespace

Symfony\Component\Validator\Tests\Validator

Code

public function testTraversalDisabledOnClass() {
  $test = $this;
  $entity = new Entity();
  $traversable = new \ArrayIterator(array(
    'key' => $entity,
  ));
  $callback = function ($value, ExecutionContextInterface $context) use ($test) {
    $test
      ->fail('Should not be called');
  };
  $traversableMetadata = new ClassMetadata('ArrayIterator');
  $traversableMetadata
    ->addConstraint(new Traverse(false));
  $this->metadataFactory
    ->addMetadata($traversableMetadata);
  $this->metadata
    ->addConstraint(new Callback(array(
    'callback' => $callback,
    'groups' => 'Group',
  )));
  $violations = $this
    ->validate($traversable, new Valid(), 'Group');

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