public function CollectionValidatorTest::testWalkMultipleConstraints

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php, line 106

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 = 1;
  foreach ($array as $key => $value) {
    foreach ($constraints as $constraint) {
      $this->context
        ->expects($this
        ->at($i++))
        ->method('validateValue')
        ->with($value, $constraint, '[' . $key . ']', 'MyGroup');
    }
  }
  $data = $this
    ->prepareTestData($array);
  $this->context
    ->expects($this
    ->never())
    ->method('addViolationAt');
  $this->validator
    ->validate($data, new Collection(array(
    'fields' => array(
      'foo' => $constraints,
      'bar' => $constraints,
    ),
  )));
}