public function testValidateCascadedPropertyValidatesReferences() {
$entity = new Entity();
$entity->reference = new Entity();
// add a constraint for the entity that always fails
$this->metadata
->addConstraint(new FailingConstraint());
// validate entity when validating the property "reference"
$this->metadata
->addPropertyConstraint('reference', new Valid());
// invoke validation on an object
$this->visitor
->validate($entity, 'Default', '');
$violations = new ConstraintViolationList(array(
// generated by the root object
new ConstraintViolation('Failed', 'Failed', array(), 'Root', '', $entity),
// generated by the reference
new ConstraintViolation('Failed', 'Failed', array(), 'Root', 'reference', $entity->reference),
));
$this
->assertEquals($violations, $this->visitor
->getViolations());
}