diff --git a/tests/Bundle/DependencyInjection/Compiler/FosRestPassTest.php b/tests/Bundle/DependencyInjection/Compiler/FosRestPassTest.php new file mode 100644 index 000000000..ebecaed4e --- /dev/null +++ b/tests/Bundle/DependencyInjection/Compiler/FosRestPassTest.php @@ -0,0 +1,51 @@ +setParameter('kernel.bundles', []); + + $this->compile(); + + $this->assertContainerBuilderNotHasService('sylius.resource_controller.view_handler'); + } + + /** @test */ + public function it_keeps_the_view_handler_if_fos_rest_is_available(): void + { + $this->setParameter('kernel.bundles', [FOSRestBundle::class]); + + $this->compile(); + + $this->assertContainerBuilderHasService('sylius.resource_controller.view_handler'); + } + + protected function registerCompilerPass(ContainerBuilder $container): void + { + $this->registerService('sylius.resource_controller.view_handler', ViewHandler::class); + $this->setParameter('kernel.bundles', []); + + $container->addCompilerPass(new FosRestPass()); + } +} diff --git a/tests/Bundle/DependencyInjection/Compiler/HateoasPassTest.php b/tests/Bundle/DependencyInjection/Compiler/HateoasPassTest.php new file mode 100644 index 000000000..73397541c --- /dev/null +++ b/tests/Bundle/DependencyInjection/Compiler/HateoasPassTest.php @@ -0,0 +1,51 @@ +setParameter('kernel.bundles', []); + + $this->compile(); + + $this->assertContainerBuilderNotHasService('sylius.resource_controller.pagerfanta_representation_factory'); + } + + /** @test */ + public function it_keeps_the_view_handler_if_fos_rest_is_available(): void + { + $this->setParameter('kernel.bundles', [BazingaHateoasBundle::class]); + + $this->compile(); + + $this->assertContainerBuilderHasService('sylius.resource_controller.pagerfanta_representation_factory'); + } + + protected function registerCompilerPass(ContainerBuilder $container): void + { + $this->registerService('sylius.resource_controller.pagerfanta_representation_factory', PagerfantaFactory::class); + $this->setParameter('kernel.bundles', []); + + $container->addCompilerPass(new HateoasPass()); + } +}