diff --git a/src/Resources/config/services_test.xml b/src/Resources/config/services_test.xml deleted file mode 100644 index 0751085..0000000 --- a/src/Resources/config/services_test.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/BundleInitializationTest.php b/tests/BundleInitializationTest.php index 31ad4b6..b3398d0 100644 --- a/tests/BundleInitializationTest.php +++ b/tests/BundleInitializationTest.php @@ -3,6 +3,7 @@ namespace Shivas\VersioningBundle\Tests; +use Nyholm\BundleTest\TestKernel; use Shivas\VersioningBundle\Formatter\FormatterInterface; use Shivas\VersioningBundle\Formatter\GitDescribeFormatter; use Shivas\VersioningBundle\Provider\GitRepositoryProvider; @@ -16,30 +17,32 @@ use Shivas\VersioningBundle\Writer\VersionWriter; use Shivas\VersioningBundle\Writer\WriterInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\KernelInterface; /** * @covers \Shivas\VersioningBundle\ShivasVersioningBundle */ class BundleInitializationTest extends KernelTestCase { - protected function setUp(): void - { - parent::setUp(); - } - protected static function getKernelClass(): string { - return \Nyholm\BundleTest\TestKernel::class; + return TestKernel::class; } - protected static function createKernel(array $options = []): \Symfony\Component\HttpKernel\KernelInterface + protected static function createKernel(array $options = []): KernelInterface { - /** - * @var \Nyholm\BundleTest\TestKernel $kernel - */ + /** @var TestKernel $kernel */ $kernel = parent::createKernel($options); - $kernel->addTestConfig($kernel->getProjectDir().'/src/Resources/config/services_test.xml'); $kernel->addTestBundle(ShivasVersioningBundle::class); + $kernel->addTestCompilerPass(new class implements CompilerPassInterface { + public function process(ContainerBuilder $container): void + { + // Service would be removed because it's unused. + $container->findDefinition('shivas_versioning.twig.version')->setPublic(true); + } + }); $kernel->handleOptions($options); return $kernel;