Skip to content

Commit

Permalink
[Validator][GroupSequence] fixed GroupSequence validation ignores Pro…
Browse files Browse the repository at this point in the history
…pertyMetadata of parent classes
  • Loading branch information
senaria authored and fabpot committed Aug 26, 2016
1 parent 6de4359 commit 54a7eff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Component/Validator/Mapping/ClassMetadata.php
Expand Up @@ -350,6 +350,7 @@ public function mergeConstraints(ClassMetadata $source)
$member = clone $member;

foreach ($member->getConstraints() as $constraint) {
$member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
$constraint->addImplicitGroupName($this->getDefaultGroup());
}

Expand Down
Expand Up @@ -138,23 +138,41 @@ public function testMergeConstraintsMergesMemberConstraints()
$this->metadata->mergeConstraints($parent);
$this->metadata->addPropertyConstraint('firstName', new ConstraintA());

$constraintA1 = new ConstraintA(array('groups' => array(
'Default',
'EntityParent',
'Entity',
)));
$constraintA2 = new ConstraintA(array('groups' => array(
'Default',
'Entity',
)));

$constraints = array(
new ConstraintA(array('groups' => array(
'Default',
'EntityParent',
'Entity',
))),
new ConstraintA(array('groups' => array(
'Default',
'Entity',
))),
$constraintA1,
$constraintA2,
);

$constraintsByGroup = array(
'Default' => array(
$constraintA1,
$constraintA2,
),
'EntityParent' => array(
$constraintA1,
),
'Entity' => array(
$constraintA1,
$constraintA2,
),
);

$members = $this->metadata->getPropertyMetadata('firstName');

$this->assertCount(1, $members);
$this->assertEquals(self::PARENTCLASS, $members[0]->getClassName());
$this->assertEquals($constraints, $members[0]->getConstraints());
$this->assertEquals($constraintsByGroup, $members[0]->constraintsByGroup);
}

public function testMemberMetadatas()
Expand Down

0 comments on commit 54a7eff

Please sign in to comment.