|
23 | 23 | use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
|
24 | 24 | use ApiPlatform\Metadata\Property\PropertyNameCollection;
|
25 | 25 | use ApiPlatform\Metadata\Put;
|
| 26 | +use ApiPlatform\Metadata\Resource\Factory\AttributesResourceMetadataCollectionFactory; |
26 | 27 | use ApiPlatform\Metadata\Resource\Factory\LinkFactory;
|
27 | 28 | use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
|
28 | 29 | use ApiPlatform\Metadata\Resource\Factory\UriTemplateResourceMetadataCollectionFactory;
|
29 | 30 | use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
|
30 | 31 | use ApiPlatform\Operation\PathSegmentNameGeneratorInterface;
|
| 32 | +use ApiPlatform\Tests\Fixtures\TestBundle\ApiResourceNotLoaded\SymfonyFormatParameterLegacy; |
31 | 33 | use ApiPlatform\Tests\Fixtures\TestBundle\Entity\AttributeResource;
|
32 | 34 | use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy;
|
33 | 35 | use PHPUnit\Framework\TestCase;
|
34 | 36 | use Prophecy\Argument;
|
35 | 37 | use Prophecy\PhpUnit\ProphecyTrait;
|
| 38 | +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; |
36 | 39 |
|
37 | 40 | /**
|
38 | 41 | * @author Antoine Bluchet <[email protected]>
|
39 | 42 | */
|
40 | 43 | class UriTemplateResourceMetadataCollectionFactoryTest extends TestCase
|
41 | 44 | {
|
| 45 | + use ExpectDeprecationTrait; |
42 | 46 | use ProphecyTrait;
|
43 | 47 |
|
44 | 48 | public function testCreate(): void
|
@@ -169,4 +173,25 @@ class: AttributeResource::class,
|
169 | 173 | $uriTemplateResourceMetadataCollectionFactory->create(AttributeResource::class)
|
170 | 174 | );
|
171 | 175 | }
|
| 176 | + |
| 177 | + /** |
| 178 | + * @group legacy |
| 179 | + */ |
| 180 | + public function testCreateWithLegacyFormat(): void |
| 181 | + { |
| 182 | + $this->expectDeprecation('Since api-platform/core 3.0: The special Symfony parameter ".{_format}" in your URI Template is deprecated, use an RFC6570 variable "{._format}" on the class "ApiPlatform\Tests\Fixtures\TestBundle\ApiResourceNotLoaded\SymfonyFormatParameterLegacy" instead. We will only use the RFC6570 compatible variable in 4.0.'); |
| 183 | + |
| 184 | + $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class); |
| 185 | + $propertyNameCollectionFactoryProphecy->create(Argument::cetera())->willReturn(new PropertyNameCollection()); |
| 186 | + $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class); |
| 187 | + $resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class); |
| 188 | + $linkFactory = new LinkFactory($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceClassResolverProphecy->reveal()); |
| 189 | + $pathSegmentNameGeneratorProphecy = $this->prophesize(PathSegmentNameGeneratorInterface::class); |
| 190 | + $pathSegmentNameGeneratorProphecy->getSegmentName('SymfonyFormatParameterLegacy')->willReturn('attribute_resources'); |
| 191 | + $resourceCollectionMetadataFactoryProphecy = new AttributesResourceMetadataCollectionFactory(); |
| 192 | + |
| 193 | + $linkFactory = new LinkFactory($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceClassResolverProphecy->reveal()); |
| 194 | + $uriTemplateResourceMetadataCollectionFactory = new UriTemplateResourceMetadataCollectionFactory($linkFactory, $pathSegmentNameGeneratorProphecy->reveal(), $resourceCollectionMetadataFactoryProphecy); |
| 195 | + $uriTemplateResourceMetadataCollectionFactory->create(SymfonyFormatParameterLegacy::class); |
| 196 | + } |
172 | 197 | }
|
0 commit comments