You are here

public function CollectionValidatorTest::testWalkMultipleConstraints 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::testWalkMultipleConstraints()

File

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

Class

CollectionValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

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