You are here

public function CollectionValidatorTest::testWalkSingleConstraint in Zircon Profile 8

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

File

vendor/symfony/validator/Tests/Constraints/CollectionValidatorTest.php, line 70

Class

CollectionValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testWalkSingleConstraint() {
  $constraint = new Range(array(
    'min' => 4,
  ));
  $array = array(
    'foo' => 3,
    'bar' => 5,
  );
  $i = 0;
  foreach ($array as $key => $value) {
    $this
      ->expectValidateValueAt($i++, '[' . $key . ']', $value, array(
      $constraint,
    ));
  }
  $data = $this
    ->prepareTestData($array);
  $this->validator
    ->validate($data, new Collection(array(
    'fields' => array(
      'foo' => $constraint,
      'bar' => $constraint,
    ),
  )));
  $this
    ->assertNoViolation();
}