You are here

public function CollectionValidatorTest::testWalkMultipleConstraints in Plug 7

File

lib/Symfony/validator/Symfony/Component/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();
}