-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
tests/Bundle/DependencyInjection/Compiler/FosRestPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bundle\DependencyInjection\Compiler; | ||
|
||
use FOS\RestBundle\FOSRestBundle; | ||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; | ||
use Sylius\Bundle\ResourceBundle\Controller\ViewHandler; | ||
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\FosRestPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
final class FosRestPassTest extends AbstractCompilerPassTestCase | ||
{ | ||
/** @test */ | ||
public function it_remove_view_handler_if_fos_rest_is_not_available(): void | ||
{ | ||
$this->registerService('sylius.resource_controller.view_handler', ViewHandler::class); | ||
$this->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->registerService('sylius.resource_controller.view_handler', ViewHandler::class); | ||
$this->setParameter('kernel.bundles', [FOSRestBundle::class]); | ||
|
||
$this->compile(); | ||
|
||
$this->assertContainerBuilderHasService('sylius.resource_controller.view_handler'); | ||
} | ||
|
||
protected function registerCompilerPass(ContainerBuilder $container): void | ||
{ | ||
$container->addCompilerPass(new FosRestPass()); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/Bundle/DependencyInjection/Compiler/HateoasPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bundle\DependencyInjection\Compiler; | ||
|
||
use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle; | ||
use Hateoas\Representation\Factory\PagerfantaFactory; | ||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; | ||
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\HateoasPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
final class HateoasPassTest extends AbstractCompilerPassTestCase | ||
{ | ||
/** @test */ | ||
public function it_remove_pagerfanta_representation_factory_if_hateoas_is_not_available(): void | ||
{ | ||
$this->registerService('sylius.resource_controller.pagerfanta_representation_factory', PagerfantaFactory::class); | ||
$this->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->registerService('sylius.resource_controller.pagerfanta_representation_factory', PagerfantaFactory::class); | ||
$this->setParameter('kernel.bundles', [BazingaHateoasBundle::class]); | ||
|
||
$this->compile(); | ||
|
||
$this->assertContainerBuilderHasService('sylius.resource_controller.pagerfanta_representation_factory'); | ||
} | ||
|
||
protected function registerCompilerPass(ContainerBuilder $container): void | ||
{ | ||
$container->addCompilerPass(new HateoasPass()); | ||
} | ||
} |