|
13 | 13 |
|
14 | 14 | namespace ApiPlatform\Tests\Symfony\Bundle\DependencyInjection;
|
15 | 15 |
|
| 16 | +use ApiPlatform\Api\FilterInterface; |
16 | 17 | use ApiPlatform\Api\UrlGeneratorInterface;
|
| 18 | +use ApiPlatform\Core\DataPersister\DataPersisterInterface; |
| 19 | +use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface; |
| 20 | +use ApiPlatform\Core\DataProvider\ItemDataProviderInterface; |
| 21 | +use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface; |
17 | 22 | use ApiPlatform\Core\Tests\ProphecyTrait;
|
| 23 | +use ApiPlatform\DataTransformer\DataTransformerInitializerInterface; |
| 24 | +use ApiPlatform\DataTransformer\DataTransformerInterface; |
| 25 | +use ApiPlatform\Doctrine\Odm\Extension\AggregationCollectionExtensionInterface; |
| 26 | +use ApiPlatform\Doctrine\Odm\Extension\AggregationItemExtensionInterface; |
| 27 | +use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface as DoctrineQueryCollectionExtensionInterface; |
| 28 | +use ApiPlatform\Doctrine\Orm\Extension\QueryItemExtensionInterface; |
| 29 | +use ApiPlatform\Elasticsearch\Extension\RequestBodySearchCollectionExtensionInterface; |
| 30 | +use ApiPlatform\GraphQl\Error\ErrorHandlerInterface; |
| 31 | +use ApiPlatform\GraphQl\Resolver\MutationResolverInterface; |
| 32 | +use ApiPlatform\GraphQl\Resolver\QueryCollectionResolverInterface; |
| 33 | +use ApiPlatform\GraphQl\Resolver\QueryItemResolverInterface; |
| 34 | +use ApiPlatform\GraphQl\Type\Definition\TypeInterface as GraphQlTypeInterface; |
| 35 | +use ApiPlatform\State\ProcessorInterface; |
| 36 | +use ApiPlatform\State\ProviderInterface; |
18 | 37 | use ApiPlatform\Symfony\Bundle\DependencyInjection\ApiPlatformExtension;
|
| 38 | +use ApiPlatform\Symfony\Validator\Metadata\Property\Restriction\PropertySchemaRestrictionMetadataInterface; |
| 39 | +use ApiPlatform\Symfony\Validator\ValidationGroupsGeneratorInterface; |
19 | 40 | use Doctrine\Common\Annotations\Annotation;
|
20 | 41 | use phpDocumentor\Reflection\DocBlockFactoryInterface;
|
21 | 42 | use PHPUnit\Framework\TestCase;
|
@@ -1599,6 +1620,10 @@ public function testElasticsearchConfiguration(): void
|
1599 | 1620 | ];
|
1600 | 1621 |
|
1601 | 1622 | $this->assertContainerHas($services, $aliases, $tags);
|
| 1623 | + |
| 1624 | + $autoconfiguredInstances = $this->container->getAutoconfiguredInstanceof(); |
| 1625 | + $this->assertArrayHasKey(RequestBodySearchCollectionExtensionInterface::class, $autoconfiguredInstances); |
| 1626 | + $this->assertArrayHasKey('api_platform.elasticsearch.request_body_search_extension.collection', $autoconfiguredInstances[RequestBodySearchCollectionExtensionInterface::class]->getTags()); |
1602 | 1627 | }
|
1603 | 1628 |
|
1604 | 1629 | public function testSecurityConfiguration(): void
|
@@ -1796,4 +1821,43 @@ public function testRectorConfiguration(): void
|
1796 | 1821 |
|
1797 | 1822 | $this->assertContainerHas($services, [], $tags);
|
1798 | 1823 | }
|
| 1824 | + |
| 1825 | + public function testAutoConfigurableInterfaces(): void |
| 1826 | + { |
| 1827 | + $config = self::DEFAULT_CONFIG; |
| 1828 | + (new ApiPlatformExtension())->load($config, $this->container); |
| 1829 | + |
| 1830 | + $interfaces = [ |
| 1831 | + FilterInterface::class => 'api_platform.filter', |
| 1832 | + ProviderInterface::class => 'api_platform.state_provider', |
| 1833 | + ProcessorInterface::class => 'api_platform.state_processor', |
| 1834 | + DataPersisterInterface::class => 'api_platform.data_persister', |
| 1835 | + ItemDataProviderInterface::class => 'api_platform.item_data_provider', |
| 1836 | + CollectionDataProviderInterface::class => 'api_platform.collection_data_provider', |
| 1837 | + SubresourceDataProviderInterface::class => 'api_platform.subresource_data_provider', |
| 1838 | + DataTransformerInterface::class => 'api_platform.data_transformer', |
| 1839 | + DataTransformerInitializerInterface::class => 'api_platform.data_transformer', |
| 1840 | + ValidationGroupsGeneratorInterface::class => 'api_platform.validation_groups_generator', |
| 1841 | + PropertySchemaRestrictionMetadataInterface::class => 'api_platform.metadata.property_schema_restriction', |
| 1842 | + QueryItemResolverInterface::class => 'api_platform.graphql.query_resolver', |
| 1843 | + QueryCollectionResolverInterface::class => 'api_platform.graphql.query_resolver', |
| 1844 | + MutationResolverInterface::class => 'api_platform.graphql.mutation_resolver', |
| 1845 | + GraphQlTypeInterface::class => 'api_platform.graphql.type', |
| 1846 | + ErrorHandlerInterface::class => 'api_platform.graphql.error_handler', |
| 1847 | + QueryItemExtensionInterface::class => 'api_platform.doctrine.orm.query_extension.item', |
| 1848 | + DoctrineQueryCollectionExtensionInterface::class => 'api_platform.doctrine.orm.query_extension.collection', |
| 1849 | + AggregationItemExtensionInterface::class => 'api_platform.doctrine_mongodb.odm.aggregation_extension.item', |
| 1850 | + AggregationCollectionExtensionInterface::class => 'api_platform.doctrine_mongodb.odm.aggregation_extension.collection', |
| 1851 | + ]; |
| 1852 | + |
| 1853 | + $has = []; |
| 1854 | + foreach ($this->container->getAutoconfiguredInstanceof() as $interface => $childDefinition) { |
| 1855 | + if (isset($interfaces[$interface])) { |
| 1856 | + $has[] = $interface; |
| 1857 | + $this->assertArrayHasKey($interfaces[$interface], $childDefinition->getTags()); |
| 1858 | + } |
| 1859 | + } |
| 1860 | + |
| 1861 | + $this->assertEmpty(array_diff(array_keys($interfaces), $has), 'Not all expected interfaces are autoconfigurable.'); |
| 1862 | + } |
1799 | 1863 | }
|
0 commit comments