Skip to content

Commit 1ff0611

Browse files
committed
[Validator][GroupSequence] fixed GroupSequence validation ignores PropertyMetadata of parent classes
1 parent 4d3f25b commit 1ff0611

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ public function mergeConstraints(ClassMetadata $source)
350350
$member = clone $member;
351351

352352
foreach ($member->getConstraints() as $constraint) {
353+
$member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
353354
$constraint->addImplicitGroupName($this->getDefaultGroup());
354355
}
355356

src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,41 @@ public function testMergeConstraintsMergesMemberConstraints()
138138
$this->metadata->mergeConstraints($parent);
139139
$this->metadata->addPropertyConstraint('firstName', new ConstraintA());
140140

141+
$constraintA1 = new ConstraintA(array('groups' => array(
142+
'Default',
143+
'EntityParent',
144+
'Entity',
145+
)));
146+
$constraintA2 = new ConstraintA(array('groups' => array(
147+
'Default',
148+
'Entity',
149+
)));
150+
141151
$constraints = array(
142-
new ConstraintA(array('groups' => array(
143-
'Default',
144-
'EntityParent',
145-
'Entity',
146-
))),
147-
new ConstraintA(array('groups' => array(
148-
'Default',
149-
'Entity',
150-
))),
152+
$constraintA1,
153+
$constraintA2,
154+
);
155+
156+
$constraintsByGroup = array(
157+
'Default' => array(
158+
$constraintA1,
159+
$constraintA2,
160+
),
161+
'EntityParent' => array(
162+
$constraintA1,
163+
),
164+
'Entity' => array(
165+
$constraintA1,
166+
$constraintA2,
167+
),
151168
);
152169

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

155172
$this->assertCount(1, $members);
156173
$this->assertEquals(self::PARENTCLASS, $members[0]->getClassName());
157174
$this->assertEquals($constraints, $members[0]->getConstraints());
175+
$this->assertEquals($constraintsByGroup, $members[0]->constraintsByGroup);
158176
}
159177

160178
public function testMemberMetadatas()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy