|
49 | 49 | use Prophecy\PhpUnit\ProphecyTrait; |
50 | 50 | use Symfony\Component\PropertyInfo\Type as LegacyType; |
51 | 51 | use Symfony\Component\TypeInfo\Type; |
| 52 | +use Symfony\Component\Validator\Constraints\GroupSequence; |
52 | 53 | use Symfony\Component\Validator\Constraints\Hostname; |
53 | 54 | use Symfony\Component\Validator\Constraints\Ulid; |
54 | 55 | use Symfony\Component\Validator\Mapping\ClassMetadata; |
@@ -198,6 +199,29 @@ public function testCreateWithPropertyWithRightValidationGroupsAndRequiredConstr |
198 | 199 | $this->assertEquals($expectedPropertyMetadata, $resultedPropertyMetadata); |
199 | 200 | } |
200 | 201 |
|
| 202 | + public function testCreateWithPropertyWithGroupSequenceValidationGroupsAndRequiredConstraints(): void |
| 203 | + { |
| 204 | + $propertyMetadata = (new ApiProperty())->withDescription('A dummy group')->withReadable(true)->withWritable(true); |
| 205 | + $expectedPropertyMetadata = $propertyMetadata->withRequired(true); |
| 206 | + |
| 207 | + $groups = [new GroupSequence(['dummy'])]; |
| 208 | + |
| 209 | + $decoratedPropertyMetadataFactory = $this->prophesize(PropertyMetadataFactoryInterface::class); |
| 210 | + $decoratedPropertyMetadataFactory->create(DummyValidatedEntity::class, 'dummyGroup', ['validation_groups' => $groups])->willReturn($propertyMetadata)->shouldBeCalled(); |
| 211 | + |
| 212 | + $validatorMetadataFactory = $this->prophesize(MetadataFactoryInterface::class); |
| 213 | + $validatorMetadataFactory->getMetadataFor(DummyValidatedEntity::class)->willReturn($this->validatorClassMetadata)->shouldBeCalled(); |
| 214 | + |
| 215 | + $validatorPropertyMetadataFactory = new ValidatorPropertyMetadataFactory( |
| 216 | + $validatorMetadataFactory->reveal(), |
| 217 | + $decoratedPropertyMetadataFactory->reveal(), |
| 218 | + [] |
| 219 | + ); |
| 220 | + $resultedPropertyMetadata = $validatorPropertyMetadataFactory->create(DummyValidatedEntity::class, 'dummyGroup', ['validation_groups' => $groups]); |
| 221 | + |
| 222 | + $this->assertEquals($expectedPropertyMetadata, $resultedPropertyMetadata); |
| 223 | + } |
| 224 | + |
201 | 225 | public function testCreateWithPropertyWithBadValidationGroupsAndRequiredConstraints(): void |
202 | 226 | { |
203 | 227 | $propertyMetadata = (new ApiProperty())->withDescription('A dummy group')->withReadable(true)->withWritable(true); |
|
0 commit comments