Skip to content

Commit

Permalink
fix: fix a missing service definition in test environment (#5206)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkrovitch committed Nov 24, 2022
1 parent 096ac11 commit 3939857
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ final class DeprecateMercurePublisherPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$container
->setAlias('api_platform.doctrine.listener.mercure.publish', 'api_platform.doctrine.orm.listener.mercure.publish')
->setDeprecated(...$this->buildDeprecationArgs('2.6', 'Using "%alias_id%" service is deprecated since API Platform 2.6. Use "api_platform.doctrine.orm.listener.mercure.publish" instead.'));
if ($container->hasDefinition('api_platform.doctrine.listener.mercure.publish')) {
$container
->setAlias('api_platform.doctrine.listener.mercure.publish', 'api_platform.doctrine.orm.listener.mercure.publish')
->setDeprecated(...$this->buildDeprecationArgs('2.6', 'Using "%alias_id%" service is deprecated since API Platform 2.6. Use "api_platform.doctrine.orm.listener.mercure.publish" instead.'));
}
}

private function buildDeprecationArgs(string $version, string $message): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class DeprecateMercurePublisherPassTest extends TestCase
{
use ProphecyTrait;

public function testProcess()
public function testProcess(): void
{
$deprecateMercurePublisherPass = new DeprecateMercurePublisherPass();

Expand All @@ -34,6 +34,10 @@ public function testProcess()
$containerBuilderProphecy = $this->prophesize(ContainerBuilder::class);
$aliasProphecy = $this->prophesize(Alias::class);

$containerBuilderProphecy
->hasDefinition('api_platform.doctrine.listener.mercure.publish')
->willReturn(true);

$containerBuilderProphecy
->setAlias('api_platform.doctrine.listener.mercure.publish', 'api_platform.doctrine.orm.listener.mercure.publish')
->willReturn($aliasProphecy->reveal())
Expand All @@ -50,4 +54,20 @@ public function testProcess()

$deprecateMercurePublisherPass->process($containerBuilderProphecy->reveal());
}

public function testProcessWithoutDefinition(): void
{
$deprecateMercurePublisherPass = new DeprecateMercurePublisherPass();
$containerBuilderProphecy = $this->prophesize(ContainerBuilder::class);

$containerBuilderProphecy
->hasDefinition('api_platform.doctrine.listener.mercure.publish')
->willReturn(false);

$containerBuilderProphecy
->setAlias('api_platform.doctrine.listener.mercure.publish', 'api_platform.doctrine.orm.listener.mercure.publish')
->shouldNotBeCalled();

$deprecateMercurePublisherPass->process($containerBuilderProphecy->reveal());
}
}

0 comments on commit 3939857

Please sign in to comment.