You are here

public function AbstractValidatorTest::testValidateObjectOnlyOncePerGroup 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::testValidateObjectOnlyOncePerGroup()

File

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

Class

AbstractValidatorTest
@since 2.5

Namespace

Symfony\Component\Validator\Tests\Validator

Code

public function testValidateObjectOnlyOncePerGroup() {
  $entity = new Entity();
  $entity->reference = new Reference();
  $entity->reference2 = $entity->reference;
  $callback = function ($value, ExecutionContextInterface $context) {
    $context
      ->addViolation('Message');
  };
  $this->metadata
    ->addPropertyConstraint('reference', new Valid());
  $this->metadata
    ->addPropertyConstraint('reference2', new Valid());
  $this->referenceMetadata
    ->addConstraint(new Callback($callback));
  $violations = $this
    ->validate($entity);

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