|
76 | 76 | use Prophecy\Argument;
|
77 | 77 | use Prophecy\Exception\Doubler\MethodNotFoundException;
|
78 | 78 | use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
| 79 | +use Symfony\Component\Cache\Adapter\ArrayAdapter; |
79 | 80 | use Symfony\Component\Config\FileLocator;
|
80 | 81 | use Symfony\Component\Config\Resource\DirectoryResource;
|
81 | 82 | use Symfony\Component\Config\Resource\ResourceInterface;
|
@@ -133,7 +134,7 @@ protected function setUp()
|
133 | 134 | $this->childDefinitionProphecy = $this->prophesize(ChildDefinition::class);
|
134 | 135 | }
|
135 | 136 |
|
136 |
| - public function tearDown() |
| 137 | + protected function tearDown() |
137 | 138 | {
|
138 | 139 | unset($this->extension);
|
139 | 140 | }
|
@@ -603,6 +604,58 @@ public function testEnableElasticsearch()
|
603 | 604 | $this->extension->load($config, $containerBuilderProphecy->reveal());
|
604 | 605 | }
|
605 | 606 |
|
| 607 | + /** |
| 608 | + * @group legacy |
| 609 | + * @expectedDeprecation The "api_platform.metadata_cache" parameter is deprecated since version 2.4 and will have no effect in 3.0. |
| 610 | + */ |
| 611 | + public function testDisableMetadataCache() |
| 612 | + { |
| 613 | + $containerBuilderProphecy = $this->getBaseContainerBuilderProphecy(); |
| 614 | + $containerBuilderProphecy->hasParameter('api_platform.metadata_cache')->willReturn(true); |
| 615 | + $containerBuilderProphecy->getParameter('api_platform.metadata_cache')->willReturn(false); |
| 616 | + $containerBuilderProphecy->removeDefinition('api_platform.cache_warmer.cache_pool_clearer')->shouldBeCalled(); |
| 617 | + $containerBuilderProphecy->register('api_platform.cache.metadata.property', ArrayAdapter::class)->shouldBeCalled(); |
| 618 | + $containerBuilderProphecy->register('api_platform.cache.metadata.resource', ArrayAdapter::class)->shouldBeCalled(); |
| 619 | + $containerBuilderProphecy->register('api_platform.cache.route_name_resolver', ArrayAdapter::class)->shouldBeCalled(); |
| 620 | + $containerBuilderProphecy->register('api_platform.cache.identifiers_extractor', ArrayAdapter::class)->shouldBeCalled(); |
| 621 | + $containerBuilderProphecy->register('api_platform.cache.subresource_operation_factory', ArrayAdapter::class)->shouldBeCalled(); |
| 622 | + $containerBuilderProphecy->register('api_platform.elasticsearch.cache.metadata.document', ArrayAdapter::class)->shouldBeCalled(); |
| 623 | + |
| 624 | + $containerBuilder = $containerBuilderProphecy->reveal(); |
| 625 | + |
| 626 | + $this->extension->load(self::DEFAULT_CONFIG, $containerBuilder); |
| 627 | + } |
| 628 | + |
| 629 | + public function testRemoveCachePoolClearerCacheWarmerWithoutDebug() |
| 630 | + { |
| 631 | + $containerBuilderProphecy = $this->getBaseContainerBuilderProphecy(); |
| 632 | + $containerBuilderProphecy->hasParameter('kernel.debug')->willReturn(true); |
| 633 | + $containerBuilderProphecy->getParameter('kernel.debug')->willReturn(false); |
| 634 | + $containerBuilderProphecy->removeDefinition('api_platform.cache_warmer.cache_pool_clearer')->shouldBeCalled(); |
| 635 | + |
| 636 | + $containerBuilder = $containerBuilderProphecy->reveal(); |
| 637 | + |
| 638 | + $this->extension->load(self::DEFAULT_CONFIG, $containerBuilder); |
| 639 | + } |
| 640 | + |
| 641 | + public function testKeepCachePoolClearerCacheWarmerWithDebug() |
| 642 | + { |
| 643 | + $containerBuilderProphecy = $this->getBaseContainerBuilderProphecy(); |
| 644 | + $containerBuilderProphecy->hasParameter('kernel.debug')->willReturn(true); |
| 645 | + $containerBuilderProphecy->getParameter('kernel.debug')->willReturn(true); |
| 646 | + $containerBuilderProphecy->removeDefinition('api_platform.cache_warmer.cache_pool_clearer')->shouldNotBeCalled(); |
| 647 | + |
| 648 | + // irrelevant, but to prevent errors |
| 649 | + $containerBuilderProphecy->setDefinition('debug.api_platform.collection_data_provider', Argument::type(Definition::class))->will(function () {}); |
| 650 | + $containerBuilderProphecy->setDefinition('debug.api_platform.item_data_provider', Argument::type(Definition::class))->will(function () {}); |
| 651 | + $containerBuilderProphecy->setDefinition('debug.api_platform.subresource_data_provider', Argument::type(Definition::class))->will(function () {}); |
| 652 | + $containerBuilderProphecy->setDefinition('debug.api_platform.data_persister', Argument::type(Definition::class))->will(function () {}); |
| 653 | + |
| 654 | + $containerBuilder = $containerBuilderProphecy->reveal(); |
| 655 | + |
| 656 | + $this->extension->load(self::DEFAULT_CONFIG, $containerBuilder); |
| 657 | + } |
| 658 | + |
606 | 659 | private function getPartialContainerBuilderProphecy()
|
607 | 660 | {
|
608 | 661 | $containerBuilderProphecy = $this->prophesize(ContainerBuilder::class);
|
@@ -708,31 +761,29 @@ private function getPartialContainerBuilderProphecy()
|
708 | 761 | $containerBuilderProphecy->hasExtension('http://symfony.com/schema/dic/services')->shouldBeCalled();
|
709 | 762 |
|
710 | 763 | $definitions = [
|
711 |
| - 'api_platform.data_persister', |
712 | 764 | 'api_platform.action.documentation',
|
713 |
| - 'api_platform.action.placeholder', |
714 | 765 | 'api_platform.action.entrypoint',
|
715 | 766 | 'api_platform.action.exception',
|
716 | 767 | 'api_platform.action.placeholder',
|
717 |
| - 'api_platform.cache.metadata.property', |
718 | 768 | 'api_platform.cache.identifiers_extractor',
|
| 769 | + 'api_platform.cache.metadata.property', |
719 | 770 | 'api_platform.cache.metadata.resource',
|
720 | 771 | 'api_platform.cache.route_name_resolver',
|
721 | 772 | 'api_platform.cache.subresource_operation_factory',
|
| 773 | + 'api_platform.cache_warmer.cache_pool_clearer', |
722 | 774 | 'api_platform.collection_data_provider',
|
723 |
| - 'api_platform.formats_provider', |
724 |
| - 'api_platform.filter_locator', |
| 775 | + 'api_platform.data_persister', |
725 | 776 | 'api_platform.filter_collection_factory',
|
| 777 | + 'api_platform.filter_locator', |
726 | 778 | 'api_platform.filters',
|
| 779 | + 'api_platform.formats_provider', |
727 | 780 | 'api_platform.identifiers_extractor',
|
728 | 781 | 'api_platform.identifiers_extractor.cached',
|
729 | 782 | 'api_platform.iri_converter',
|
730 | 783 | 'api_platform.identifier.converter',
|
731 |
| - 'api_platform.identifier.integer', |
732 | 784 | 'api_platform.identifier.date_normalizer',
|
| 785 | + 'api_platform.identifier.integer', |
733 | 786 | 'api_platform.identifier.uuid_normalizer',
|
734 |
| - 'api_platform.identifiers_extractor', |
735 |
| - 'api_platform.identifiers_extractor.cached', |
736 | 787 | 'api_platform.item_data_provider',
|
737 | 788 | 'api_platform.listener.exception',
|
738 | 789 | 'api_platform.listener.exception.validation',
|
@@ -779,14 +830,14 @@ private function getPartialContainerBuilderProphecy()
|
779 | 830 | 'api_platform.router',
|
780 | 831 | 'api_platform.serializer.context_builder',
|
781 | 832 | 'api_platform.serializer.context_builder.filter',
|
782 |
| - 'api_platform.serializer.property_filter', |
783 | 833 | 'api_platform.serializer.group_filter',
|
784 | 834 | 'api_platform.serializer.normalizer.item',
|
785 | 835 | 'api_platform.serializer.normalizer.item.non_resource',
|
| 836 | + 'api_platform.serializer.property_filter', |
| 837 | + 'api_platform.serializer_locator', |
786 | 838 | 'api_platform.subresource_data_provider',
|
787 | 839 | 'api_platform.subresource_operation_factory',
|
788 | 840 | 'api_platform.subresource_operation_factory.cached',
|
789 |
| - 'api_platform.serializer_locator', |
790 | 841 | 'api_platform.validator',
|
791 | 842 | ];
|
792 | 843 |
|
@@ -1035,8 +1086,10 @@ private function getBaseContainerBuilderProphecy()
|
1035 | 1086 | $containerBuilderProphecy->setAlias($alias, $service)->shouldBeCalled();
|
1036 | 1087 | }
|
1037 | 1088 |
|
1038 |
| - $containerBuilderProphecy->hasParameter('api_platform.metadata_cache')->willReturn(true)->shouldBeCalled(); |
1039 |
| - $containerBuilderProphecy->getParameter('api_platform.metadata_cache')->willReturn(true)->shouldBeCalled(); |
| 1089 | + $containerBuilderProphecy->hasParameter('api_platform.metadata_cache')->willReturn(false); |
| 1090 | + |
| 1091 | + // irrelevant, but to prevent errors |
| 1092 | + $containerBuilderProphecy->removeDefinition('api_platform.cache_warmer.cache_pool_clearer')->will(function () {}); |
1040 | 1093 |
|
1041 | 1094 | $containerBuilderProphecy->getDefinition('api_platform.mercure.listener.response.add_link_header')->willReturn(new Definition());
|
1042 | 1095 |
|
|
0 commit comments