public function CollectionValidatorTest::testExtraFieldsDisallowed in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Tests/Constraints/CollectionValidatorTest.php \Symfony\Component\Validator\Tests\Constraints\CollectionValidatorTest::testExtraFieldsDisallowed()
File
- vendor/
symfony/ validator/ Tests/ Constraints/ CollectionValidatorTest.php, line 127
Class
Namespace
Symfony\Component\Validator\Tests\ConstraintsCode
public function testExtraFieldsDisallowed() {
$constraint = new Range(array(
'min' => 4,
));
$data = $this
->prepareTestData(array(
'foo' => 5,
'baz' => 6,
));
$this
->expectValidateValueAt(0, '[foo]', $data['foo'], array(
$constraint,
));
$this->validator
->validate($data, new Collection(array(
'fields' => array(
'foo' => $constraint,
),
'extraFieldsMessage' => 'myMessage',
)));
$this
->buildViolation('myMessage')
->setParameter('{{ field }}', '"baz"')
->atPath('property.path[baz]')
->setInvalidValue(6)
->setCode(Collection::NO_SUCH_FIELD_ERROR)
->assertRaised();
}