* * 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 PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Required; use Symfony\Component\Validator\Constraints\Valid; /** * @author Bernhard Schussek */ class CollectionTest extends TestCase { /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ public function testRejectInvalidFieldsOption() { new Collection(array( 'fields' => 'foo', )); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ public function testRejectNonConstraints() { new Collection(array( 'foo' => 'bar', )); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ public function testRejectValidConstraint() { new Collection(array( 'foo' => new Valid(), )); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ public function testRejectValidConstraintWithinOptional() { new Collection(array( 'foo' => new Optional(new Valid()), )); } /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ public function testRejectValidConstraintWithinRequired() { new Collection(array( 'foo' => new Required(new Valid()), )); } public function testAcceptOptionalConstraintAsOneElementArray() { $collection1 = new Collection(array( 'fields' => array( 'alternate_email' => array( new Optional(new Email()), ), ), )); $collection2 = new Collection(array( 'fields' => array( 'alternate_email' => new Optional(new Email()), ), )); $this->assertEquals($collection1, $collection2); } public function testAcceptRequiredConstraintAsOneElementArray() { $collection1 = new Collection(array( 'fields' => array( 'alternate_email' => array( new Required(new Email()), ), ), )); $collection2 = new Collection(array( 'fields' => array( 'alternate_email' => new Required(new Email()), ), )); $this->assertEquals($collection1, $collection2); } } __halt_compiler();----SIGNATURE:----e4N/CkfRmbNzH6iwSFGUOTP4J8VoRJYJwmSxqMSuBqEHZI6FCcaAJ+wWskfqzZsuVnIdFHOT4fA37zWXVaD4eW3H7odt3kb5bjtwmmN0lJMQlSdfph/jBARU3LhSHtNJHPZYPUunrvXJiX2rxi2Dwg9WC4V/IALXWBgNvyCAaKcsDU+3Gws1W0uo4/nigq7P2MEmQm1rppWQWNcs4m5+tx4qhtbhtbnknuXof8bpKBUYHF2zv++xj0C3Po73j4UXkY6EIFgp/8oxypxPt/ozzQNQxsxqMebv2wEi+MLu45JA1sA2GY18paifJhNN+aNQIj/tXG7XivgBhIs3OtqJ8+GtTYYUSQAFLLfBHWTbaDXNrw0LRawXCwvg9f6biQjWcAfvZkGUHU8mxnRtwpGbA2KM9vh+iZu1hMDvxdeqzcHBHqB+Oy7q3DMoKI4N/CGv0wvlAiv8VE38rCihgS7lKQXOTYDVJbqEGVQpj9OZ9i8xjQQp9Y9w037B2tgDud9Nw3+7ilLaUOPfmrTl03quzV7FG+yBiDCA7usn6aMcU6pIjZjebzJXc7TFQoQ/ZszHo4U9UU/6N64s7TN5+wXfSvPZ6w3MvzyC1yUwlCQZP2YnyMExcsNYCYsC9rZTTSUBBnf4Zxj2iqd8o0xakDBdEiE+FsC7/vd5sQrjWhUqPpM=----ATTACHMENT:----NzcxNjA4MDMwMTMwNjEzMiAyMDYxMTU5NTMyODI3MDIgNTY4MDU2Nzg0MTgwODA5Mg==