Skip to content

Commit 50bcceb

Browse files
committed
improve tests
1 parent 1655204 commit 50bcceb

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

tests/Unit/TestCaseAllPublicCompilerPass.php renamed to tests/Unit/AllPublicCompilerPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
88
use Symfony\Component\DependencyInjection\ContainerBuilder;
99

10-
final class TestCaseAllPublicCompilerPass implements CompilerPassInterface
10+
final class AllPublicCompilerPass implements CompilerPassInterface
1111
{
1212
private const SERVICE_PREFIX = 'event_sourcing.';
1313
private const NAMESPACE_PREFIX = 'Patchlevel\\';
@@ -21,7 +21,7 @@ public function process(ContainerBuilder $container): void
2121
}
2222

2323
foreach ($container->getAliases() as $id => $alias) {
24-
if ($this->isOwnService($id)) {
24+
if ($this->isOwnService($id) || $this->isOwnService((string)$alias)) {
2525
$alias->setPublic(true);
2626
}
2727
}

tests/Unit/NoLazyCompilerPass.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Patchlevel\EventSourcingBundle\Tests\Unit;
4+
5+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
8+
final class NoLazyCompilerPass implements CompilerPassInterface
9+
{
10+
public function process(ContainerBuilder $container): void
11+
{
12+
foreach ($container->getDefinitions() as $definition) {
13+
$definition->setLazy(false);
14+
}
15+
}
16+
}

tests/Unit/PatchlevelEventSourcingBundleTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use ArrayObject;
66
use Doctrine\DBAL\Connection;
7-
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
87
use Doctrine\Migrations\Tools\Console\Command\CurrentCommand;
98
use Doctrine\Migrations\Tools\Console\Command\DiffCommand;
109
use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
@@ -378,6 +377,7 @@ public function testMigrateStore(): void
378377
$container = new ContainerBuilder();
379378

380379
$container->register('my_translator', ExcludeEventWithHeaderTranslator::class)
380+
->setPublic(true)
381381
->setArguments([ArchivedHeader::class]);
382382

383383
$this->compileContainer(
@@ -1629,10 +1629,6 @@ private function compileContainer(ContainerBuilder $container, array $config): v
16291629
$container->setParameter('kernel.project_dir', __DIR__);
16301630

16311631
$connection = $this->createMock(Connection::class);
1632-
$connection
1633-
->expects($this->never())
1634-
->method('getDatabasePlatform')
1635-
->willReturn(new PostgreSQLPlatform());
16361632

16371633
$container->set('doctrine.dbal.eventstore_connection', $connection);
16381634
$container->set('event.bus', $this->createMock(MessageBusInterface::class));
@@ -1648,10 +1644,19 @@ private function compileContainer(ContainerBuilder $container, array $config): v
16481644

16491645
$compilerPassConfig = $container->getCompilerPassConfig();
16501646
$compilerPassConfig->setRemovingPasses([]);
1651-
$compilerPassConfig->addPass(new TestCaseAllPublicCompilerPass());
1647+
$compilerPassConfig->addPass(new AllPublicCompilerPass());
1648+
$compilerPassConfig->addPass(new NoLazyCompilerPass());
16521649

16531650
$container->compile();
16541651

1652+
foreach ($container->getServiceIds() as $id) {
1653+
if (str_ends_with($id, '.inner')) {
1654+
continue;
1655+
}
1656+
1657+
$container->get($id);
1658+
}
1659+
16551660
(new XmlDumper($container))->dump();
16561661
}
16571662
}

0 commit comments

Comments
 (0)