You are here

public function Abstract2Dot5ApiTest::testGroupSequenceAbortsAfterFailedGroup in Zircon Profile 8

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

File

vendor/symfony/validator/Tests/Validator/Abstract2Dot5ApiTest.php, line 85

Class

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

Namespace

Symfony\Component\Validator\Tests\Validator

Code

public function testGroupSequenceAbortsAfterFailedGroup() {
  $entity = new Entity();
  $callback1 = function ($value, ExecutionContextInterface $context) {
    $context
      ->addViolation('Message 1');
  };
  $callback2 = function ($value, ExecutionContextInterface $context) {
    $context
      ->addViolation('Message 2');
  };
  $this->metadata
    ->addConstraint(new Callback(array(
    'callback' => function () {
    },
    'groups' => 'Group 1',
  )));
  $this->metadata
    ->addConstraint(new Callback(array(
    'callback' => $callback1,
    'groups' => 'Group 2',
  )));
  $this->metadata
    ->addConstraint(new Callback(array(
    'callback' => $callback2,
    'groups' => 'Group 3',
  )));
  $sequence = new GroupSequence(array(
    'Group 1',
    'Group 2',
    'Group 3',
  ));
  $violations = $this->validator
    ->validate($entity, new Valid(), $sequence);

  /* @var ConstraintViolationInterface[] $violations */
  $this
    ->assertCount(1, $violations);
  $this
    ->assertSame('Message 1', $violations[0]
    ->getMessage());
}