* * 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:----cAlaAHRwyGtITuDpHz5HNs6XwGoHO0X/6JoY4OE9903GmvKL1dH+NcCqrdsI9a1xIKqawFOY9U5RkhKmEdDi+2QJStHA9shKJ57JXhY4w8TcyP1yCnNo0kl0S+Ja5ubW6BvO3ouGjRRC6P7LSq9vCoLlKRriwPXVWGu5/C94wyLQgkAQfBA657pFTcx9eOfmk5ZhlC1EFgMZ+c10dnc+DqOPihwATQ0mbsIJchEAFW6RacBXHQ2zRF1JVnFmeHYBjPNhMmDskLNK8n9pd28cInQuD2slikerJdNnhH+eHmhDv/8dzsNs3CWqIR4DrcBgVEyxly+jenGB+xkP/DgQA1NjC6FXFGLQwYsfyVa4z3cALyPwd1L+a4mGcnYJxBGQF4v0xgP8i9nqt2RofrMCFQqcGY+wrRLY7pRlc8PqzrY04xDDXJRGABNKabj//uR2vIeqApwOaLcrilQyiwud8/DkKK0DLL8f7sgA94e5M/CX1tLL6ffJqIf6Qhjlcx6ejy4ceap5BGM6btHZpqo+yuO6Xw8ARiTvvygfgIWYP0UpFbbVeQO+y0WpiWCLd8m14FSx2t3x7qDObRvUBODPnoZETmzWipXUfdcygS9S3Ba1v+jK9Vgv7xfrhY4SJNI6zwwc4KEcAxDdWyn8By6DwZcTrR5SHw9CqB6/UtH/FIM=----ATTACHMENT:----MzA2ODA2MjU3MTk0NjA0NyA5OTM0NDQyNjcwODYzNzAyIDU0NTI1NTUxODMzNjUxNDc=