File
- drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php, line 285
Class
- CollectionValidatorTest
Namespace
Symfony\Component\Validator\Tests\Constraints
Code
public function testOptionalFieldMultipleConstraints() {
$array = array(
'foo' => 5,
);
$constraints = array(
new NotNull(),
new Range(array(
'min' => 4,
)),
);
$i = 1;
foreach ($constraints as $constraint) {
$this->context
->expects($this
->at($i++))
->method('validateValue')
->with($array['foo'], $constraint, '[foo]', 'MyGroup');
}
$this->context
->expects($this
->never())
->method('addViolationAt');
$data = $this
->prepareTestData($array);
$this->validator
->validate($data, new Collection(array(
'foo' => new Optional($constraints),
)));
}