Skip to content

Commit a965d68

Browse files
author
Maximilian Zumbansen
committed
[Validator] add setGroupProvider to AttributeLoader
1 parent 1f1e9aa commit a965d68

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Symfony/Component/Validator/Mapping/Loader/AttributeLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool
3737
if ($constraint instanceof GroupSequence) {
3838
$metadata->setGroupSequence($constraint->groups);
3939
} elseif ($constraint instanceof GroupSequenceProvider) {
40+
$metadata->setGroupProvider($constraint->provider);
4041
$metadata->setGroupSequenceProvider(true);
4142
} elseif ($constraint instanceof Constraint) {
4243
$metadata->addConstraint($constraint);

src/Symfony/Component/Validator/Tests/Mapping/Loader/AttributeLoaderTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,22 @@ public function testLoadGroupSequenceProviderAttribute()
210210
$this->assertEquals($expected, $metadata);
211211
}
212212

213+
public function testLoadExternalGroupSequenceProvider()
214+
{
215+
$loader = $this->createAttributeLoader();
216+
$namespace = $this->getFixtureAttributeNamespace();
217+
218+
$metadata = new ClassMetadata($namespace.'\GroupProviderDto');
219+
$loader->loadClassMetadata($metadata);
220+
221+
$expected = new ClassMetadata($namespace.'\GroupProviderDto');
222+
$expected->setGroupProvider('Symfony\Component\Validator\Tests\Dummy\DummyGroupProvider');
223+
$expected->setGroupSequenceProvider(true);
224+
$expected->getReflectionClass();
225+
226+
$this->assertEquals($expected, $metadata);
227+
}
228+
213229
protected function createAttributeLoader(): AttributeLoader
214230
{
215231
return new AttributeLoader();
@@ -219,4 +235,9 @@ protected function getFixtureNamespace(): string
219235
{
220236
return 'Symfony\Component\Validator\Tests\Fixtures\NestedAttribute';
221237
}
238+
239+
protected function getFixtureAttributeNamespace(): string
240+
{
241+
return 'Symfony\Component\Validator\Tests\Fixtures\Attribute';
242+
}
222243
}

0 commit comments

Comments
 (0)