* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\AllValidator; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class AllValidatorTest extends ConstraintValidatorTestCase { protected function createValidator() { return new AllValidator(); } public function testNullIsValid() { $this->validator->validate(null, new All(new Range(array('min' => 4)))); $this->assertNoViolation(); } /** * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException */ public function testThrowsExceptionIfNotTraversable() { $this->validator->validate('foo.barbar', new All(new Range(array('min' => 4)))); } /** * @dataProvider getValidArguments */ public function testWalkSingleConstraint($array) { $constraint = new Range(array('min' => 4)); $i = 0; foreach ($array as $key => $value) { $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint)); } $this->validator->validate($array, new All($constraint)); $this->assertNoViolation(); } /** * @dataProvider getValidArguments */ public function testWalkMultipleConstraints($array) { $constraint1 = new Range(array('min' => 4)); $constraint2 = new NotNull(); $constraints = array($constraint1, $constraint2); $i = 0; foreach ($array as $key => $value) { $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint1, $constraint2)); } $this->validator->validate($array, new All($constraints)); $this->assertNoViolation(); } public function getValidArguments() { return array( array(array(5, 6, 7)), array(new \ArrayObject(array(5, 6, 7))), ); } } __halt_compiler();----SIGNATURE:----JoN9Q0MHn1FieFU5Rk/TKs816sf3dTzmT3vkbzZaRzHxg9JNrP1xgrRRn26FyHfI0t8WOv0cLlBYuj394DKui4ss4+qMRb4fuRlaiIBQBRfobIYBpGqlXrTeE0wat28BfdBMhKArUlu/lTozKsdKKmCvL5zQewXacGijwbx4QmjTam/RO2/SHTvoDivL6J4j/5uVcPg0bJB+idrkifVTD0N3kBBycuvuPre8T0VuTby79/2WTJx0xiG3HBMmNohyMbLMmTnaXE/N0zJGZfUpgRQZ2KsdonHgzAYmCJMbFrm6jfo53C9Qp9hldu3EZn1BAeDvjelqnEIOxR+3vqJnj5dyzGGxk0CFWsQCOJ6wYi9lU8hw5ysSzIx0n77j29A7ihOqskblY0k2KT5xnMfjWS5Zcg65n1hsSVdwbkwE9LJICVZZkj5QnL2ZKGHl2VcFm3j9fwilCD5KiVFd9hCUXdmg99Pf+Fo5sCFHZcxSpDG51U6Y0f7Sa5Q8p28vfJYhZZ4WoIRmmQeszRL8ojW8MBZB7QHE765Jb01AuVAcKwMpZL92+oscrzXLFHUCtQWQSc1ELs5G7n4DYPIdNerhuayXDrZ5l5IneRcgpidpbDEgbfvJGsLfxPC0IiRrJuH253PtejelPwkx2pPWEHhsJsX8j3qFA/pN4NkXJriCOYo=----ATTACHMENT:----OTAxMjYzODU0Nzg2MjEyOSA0MjQzMTcyODQ2Mzc0NzI1IDUyMjQ0ODI0ODg1NjQ3Njg=