Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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\\';
Expand All @@ -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);
}
}

Expand Down
16 changes: 16 additions & 0 deletions tests/Unit/NoLazyCompilerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Patchlevel\EventSourcingBundle\Tests\Unit;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class NoLazyCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
foreach ($container->getDefinitions() as $definition) {
$definition->setLazy(false);
}
}
}
17 changes: 11 additions & 6 deletions tests/Unit/PatchlevelEventSourcingBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -369,6 +368,7 @@ public function testMigrateStore(): void
$container = new ContainerBuilder();

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

$this->compileContainer(
Expand Down Expand Up @@ -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));
Expand All @@ -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();
}
}
Loading