From c5fe197608ee50875befdbe4144d30a531d0527b Mon Sep 17 00:00:00 2001 From: David Badura Date: Wed, 25 Mar 2026 07:51:33 +0100 Subject: [PATCH] improve tests --- ...mpilerPass.php => AllPublicCompilerPass.php} | 8 +++----- tests/Unit/NoLazyCompilerPass.php | 16 ++++++++++++++++ .../Unit/PatchlevelEventSourcingBundleTest.php | 17 +++++++++++------ 3 files changed, 30 insertions(+), 11 deletions(-) rename tests/Unit/{TestCaseAllPublicCompilerPass.php => AllPublicCompilerPass.php} (83%) create mode 100644 tests/Unit/NoLazyCompilerPass.php diff --git a/tests/Unit/TestCaseAllPublicCompilerPass.php b/tests/Unit/AllPublicCompilerPass.php similarity index 83% rename from tests/Unit/TestCaseAllPublicCompilerPass.php rename to tests/Unit/AllPublicCompilerPass.php index c9fbbafd..0549fdf8 100644 --- a/tests/Unit/TestCaseAllPublicCompilerPass.php +++ b/tests/Unit/AllPublicCompilerPass.php @@ -9,7 +9,7 @@ use function str_starts_with; -final class TestCaseAllPublicCompilerPass implements CompilerPassInterface +final class AllPublicCompilerPass implements CompilerPassInterface { private const SERVICE_PREFIX = 'event_sourcing.'; private const NAMESPACE_PREFIX = 'Patchlevel\\'; @@ -25,11 +25,9 @@ public function process(ContainerBuilder $container): void } foreach ($container->getAliases() as $id => $alias) { - if (!$this->isOwnService($id)) { - continue; + if ($this->isOwnService($id) || $this->isOwnService((string)$alias)) { + $alias->setPublic(true); } - - $alias->setPublic(true); } } diff --git a/tests/Unit/NoLazyCompilerPass.php b/tests/Unit/NoLazyCompilerPass.php new file mode 100644 index 00000000..10054305 --- /dev/null +++ b/tests/Unit/NoLazyCompilerPass.php @@ -0,0 +1,16 @@ +getDefinitions() as $definition) { + $definition->setLazy(false); + } + } +} \ No newline at end of file diff --git a/tests/Unit/PatchlevelEventSourcingBundleTest.php b/tests/Unit/PatchlevelEventSourcingBundleTest.php index 1046a80d..099674a4 100644 --- a/tests/Unit/PatchlevelEventSourcingBundleTest.php +++ b/tests/Unit/PatchlevelEventSourcingBundleTest.php @@ -6,7 +6,6 @@ use ArrayObject; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\Migrations\Tools\Console\Command\CurrentCommand; use Doctrine\Migrations\Tools\Console\Command\DiffCommand; use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand; @@ -369,6 +368,7 @@ public function testMigrateStore(): void $container = new ContainerBuilder(); $container->register('my_translator', ExcludeEventWithHeaderTranslator::class) + ->setPublic(true) ->setArguments([ArchivedHeader::class]); $this->compileContainer( @@ -1575,10 +1575,6 @@ private function compileContainer(ContainerBuilder $container, array $config): v $container->setParameter('kernel.project_dir', __DIR__); $connection = $this->createMock(Connection::class); - $connection - ->expects($this->never()) - ->method('getDatabasePlatform') - ->willReturn(new PostgreSQLPlatform()); $container->set('doctrine.dbal.eventstore_connection', $connection); $container->set('event.bus', $this->createMock(MessageBusInterface::class)); @@ -1594,10 +1590,19 @@ private function compileContainer(ContainerBuilder $container, array $config): v $compilerPassConfig = $container->getCompilerPassConfig(); $compilerPassConfig->setRemovingPasses([]); - $compilerPassConfig->addPass(new TestCaseAllPublicCompilerPass()); + $compilerPassConfig->addPass(new AllPublicCompilerPass()); + $compilerPassConfig->addPass(new NoLazyCompilerPass()); $container->compile(); + foreach ($container->getServiceIds() as $id) { + if (str_ends_with($id, '.inner')) { + continue; + } + + $container->get($id); + } + (new XmlDumper($container))->dump(); } }