X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Fvalidator%2FTests%2FConstraints%2FValidValidatorTest.php;fp=vendor%2Fsymfony%2Fvalidator%2FTests%2FConstraints%2FValidValidatorTest.php;h=c4ccf1551f2a0bec915173c4c2bc1e4afc2a148a;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/symfony/validator/Tests/Constraints/ValidValidatorTest.php b/vendor/symfony/validator/Tests/Constraints/ValidValidatorTest.php new file mode 100644 index 000000000..c4ccf1551 --- /dev/null +++ b/vendor/symfony/validator/Tests/Constraints/ValidValidatorTest.php @@ -0,0 +1,73 @@ +enableAnnotationMapping()->getValidator(); + + $violations = $validator->validate(new Foo(), null, array('nested')); + + $this->assertCount(1, $violations); + $this->assertSame('fooBar.fooBarBaz.foo', $violations->get(0)->getPropertyPath()); + } + + public function testNullValues() + { + $validatorBuilder = new ValidatorBuilder(); + $validator = $validatorBuilder->enableAnnotationMapping()->getValidator(); + + $foo = new Foo(); + $foo->fooBar = null; + $violations = $validator->validate($foo, null, array('nested')); + + $this->assertCount(0, $violations); + } + + protected function createValidator() + { + return new ValidValidator(); + } +} + +class Foo +{ + /** + * @Assert\Valid(groups={"nested"}) + */ + public $fooBar; + + public function __construct() + { + $this->fooBar = new FooBar(); + } +} + +class FooBar +{ + /** + * @Assert\Valid(groups={"nested"}) + */ + public $fooBarBaz; + + public function __construct() + { + $this->fooBarBaz = new FooBarBaz(); + } +} + +class FooBarBaz +{ + /** + * @Assert\NotBlank(groups={"nested"}) + */ + public $foo; +}