Skip to content

Commit

Permalink
Implement failing test for issue #27090
Browse files Browse the repository at this point in the history
  • Loading branch information
corphi committed Jan 6, 2019
1 parent f4ae091 commit 1207780
Showing 1 changed file with 25 additions and 0 deletions.
Expand Up @@ -589,6 +589,31 @@ public function testRecursiveArrayReference()
$this->assertNull($violations[0]->getCode());
}

// https://github.com/symfony/symfony/issues/27090
public function testOnlyCascadedArraysAreTraversed()
{
$entity = new Entity();
$entity->reference = array('key' => new Reference());

$callback = function ($value, ExecutionContextInterface $context) {
$context->addViolation('Message %param%', array('%param%' => 'value'));
};

$this->metadata->addPropertyConstraint('reference', new Callback(array(
'callback' => function () {},
'groups' => 'Group',
)));
$this->referenceMetadata->addConstraint(new Callback(array(
'callback' => $callback,
'groups' => 'Group',
)));

$violations = $this->validate($entity, null, 'Group');

/* @var ConstraintViolationInterface[] $violations */
$this->assertCount(0, $violations);
}

public function testArrayTraversalCannotBeDisabled()
{
$entity = new Entity();
Expand Down

0 comments on commit 1207780

Please sign in to comment.