|
14 | 14 | namespace ApiPlatform\Tests\Symfony\Bundle\DependencyInjection;
|
15 | 15 |
|
16 | 16 | use ApiPlatform\Api\FilterInterface;
|
| 17 | +use ApiPlatform\Api\IriConverterInterface; |
17 | 18 | use ApiPlatform\Api\UrlGeneratorInterface;
|
18 | 19 | use ApiPlatform\Core\DataPersister\DataPersisterInterface;
|
19 | 20 | use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
|
@@ -347,6 +348,7 @@ public function testCommonConfigurationWithMetadataBackwardCompatibilityLayer()
|
347 | 348 | 'api_platform.route_loader.legacy',
|
348 | 349 | 'api_platform.operation_path_resolver.router',
|
349 | 350 | 'api_platform.iri_converter.legacy',
|
| 351 | + 'api_platform.symfony.iri_converter', |
350 | 352 | 'api_platform.listener.request.add_format',
|
351 | 353 | 'api_platform.listener.request.deserialize',
|
352 | 354 | 'api_platform.listener.view.serialize',
|
@@ -386,6 +388,7 @@ public function testCommonConfigurationWithMetadataBackwardCompatibilityLayer()
|
386 | 388 | 'api_platform.metadata.resource.name_collection_factory',
|
387 | 389 | 'api_platform.route_loader',
|
388 | 390 | 'api_platform.iri_converter',
|
| 391 | + 'ApiPlatform\Api\IriConverterInterface', |
389 | 392 | 'api_platform.identifiers_extractor',
|
390 | 393 | 'api_platform.pagination',
|
391 | 394 | 'api_platform.cache.metadata.property',
|
@@ -437,11 +440,13 @@ public function testCommonConfigurationWithoutMetadataBackwardCompatibilityLayer
|
437 | 440 | 'api_platform.listener.view.write.legacy',
|
438 | 441 | 'api_platform.listener.request.read.legacy',
|
439 | 442 | 'api_platform.iri_converter',
|
| 443 | + 'api_platform.iri_converter.legacy', |
440 | 444 | ];
|
441 | 445 |
|
442 | 446 | $aliases = [
|
443 | 447 | // v3/api.xml
|
444 | 448 | 'ApiPlatform\Api\IriConverterInterface',
|
| 449 | + 'ApiPlatform\Core\Api\IriConverterInterface', |
445 | 450 | 'api_platform.identifiers_extractor',
|
446 | 451 | 'ApiPlatform\Api\IdentifiersExtractorInterface',
|
447 | 452 |
|
@@ -1819,6 +1824,30 @@ public function testLegacyServicesMetadataBackwardCompatibilityLayer(): void
|
1819 | 1824 | $this->assertNotContainerHasService('api_platform.doctrine_mongodb.odm.metadata.property.identifier_metadata_factory');
|
1820 | 1825 | }
|
1821 | 1826 |
|
| 1827 | + /** |
| 1828 | + * @dataProvider provideIriConverterAliases |
| 1829 | + */ |
| 1830 | + public function testIriConverterIsCompatibleWithAliasedInterface(bool $metadataBCLayer, string $interface): void |
| 1831 | + { |
| 1832 | + $config = self::DEFAULT_CONFIG; |
| 1833 | + $config['api_platform']['metadata_backward_compatibility_layer'] = $metadataBCLayer; |
| 1834 | + (new ApiPlatformExtension())->load($config, $this->container); |
| 1835 | + |
| 1836 | + $this->assertContainerHasAlias($interface); |
| 1837 | + |
| 1838 | + $definition = $this->container->findDefinition($interface); |
| 1839 | + $this->assertTrue(is_a($definition->getClass(), $interface, true), "Failed asserting that alias '{$interface}' resolves to a service implementing this interface."); |
| 1840 | + } |
| 1841 | + |
| 1842 | + public function provideIriConverterAliases(): \Generator |
| 1843 | + { |
| 1844 | + yield 'BC layer on, new interface' => [true, IriConverterInterface::class]; |
| 1845 | + yield 'BC layer on, legacy interface' => [true, \ApiPlatform\Core\Api\IriConverterInterface::class]; |
| 1846 | + |
| 1847 | + yield 'BC layer off, new interface' => [false, IriConverterInterface::class]; |
| 1848 | + yield 'BC layer off, legacy interface' => [false, \ApiPlatform\Core\Api\IriConverterInterface::class]; |
| 1849 | + } |
| 1850 | + |
1822 | 1851 | public function testRectorConfiguration(): void
|
1823 | 1852 | {
|
1824 | 1853 | $config = self::DEFAULT_CONFIG;
|
|
0 commit comments