|
@@ -30,6 +30,7 @@ use Symfony\Component\Validator\ConstraintViolationList;
|
|
use Symfony\Component\Validator\ConstraintValidatorFactory;
|
|
use Symfony\Component\Validator\ConstraintValidatorFactory;
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
|
use Symfony\Component\Validator\Constraints\Valid;
|
|
use Symfony\Component\Validator\Constraints\Valid;
|
|
|
|
+use Symfony\Component\Validator\Constraints\Collection;
|
|
|
|
|
|
class GraphWalkerTest extends \PHPUnit_Framework_TestCase
|
|
class GraphWalkerTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
{
|
|
@@ -411,4 +412,30 @@ class GraphWalkerTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
$this->assertEquals(0, count($this->walker->getViolations()));
|
|
$this->assertEquals(0, count($this->walker->getViolations()));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function testWalkObjectUsesCorrectPropertyPathInViolationsWhenUsingCollections()
|
|
|
|
+ {
|
|
|
|
+ $constraint = new Collection(array(
|
|
|
|
+ 'foo' => new ConstraintA(),
|
|
|
|
+ 'bar' => new ConstraintA(),
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ $this->walker->walkConstraint($constraint, array('foo' => 'VALID'), 'Default', 'collection');
|
|
|
|
+ $violations = $this->walker->getViolations();
|
|
|
|
+ $this->assertEquals('collection', $violations[0]->getPropertyPath());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function testWalkObjectUsesCorrectPropertyPathInViolationsWhenUsingNestedCollections()
|
|
|
|
+ {
|
|
|
|
+ $constraint = new Collection(array(
|
|
|
|
+ 'foo' => new Collection(array(
|
|
|
|
+ 'foo' => new ConstraintA(),
|
|
|
|
+ 'bar' => new ConstraintA(),
|
|
|
|
+ )),
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ $this->walker->walkConstraint($constraint, array('foo' => array('foo' => 'VALID')), 'Default', 'collection');
|
|
|
|
+ $violations = $this->walker->getViolations();
|
|
|
|
+ $this->assertEquals('collection[foo]', $violations[0]->getPropertyPath());
|
|
|
|
+ }
|
|
}
|
|
}
|