Skip to content

Commit

Permalink
bug #19388 [Validator][GroupSequence] fixed GroupSequence validation …
Browse files Browse the repository at this point in the history
…ignores PropetyMetadata of parent classes (Sandro Hopf)

This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes #19388).

Discussion
----------

[Validator][GroupSequence] fixed GroupSequence validation ignores PropetyMetadata of parent classes

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19387
| License       | MIT
| Doc PR        | N/A

Commits
-------

54a7eff [Validator][GroupSequence] fixed GroupSequence validation ignores PropertyMetadata of parent classes
  • Loading branch information
fabpot committed Aug 26, 2016
2 parents 6de4359 + 54a7eff commit af81c8c
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 af81c8c

Please sign in to comment.