From 79e0b510c4d3918ea9e7d9176a7dc2d5ccbc62e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6rner?= Date: Thu, 11 Apr 2024 15:08:45 +0200 Subject: [PATCH] fix test --- .../DcaField/DcaAuthorListenerTest.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/EventListener/DcaField/DcaAuthorListenerTest.php b/tests/EventListener/DcaField/DcaAuthorListenerTest.php index 43e29206..fb41168c 100644 --- a/tests/EventListener/DcaField/DcaAuthorListenerTest.php +++ b/tests/EventListener/DcaField/DcaAuthorListenerTest.php @@ -9,6 +9,7 @@ use HeimrichHannot\UtilsBundle\EventListener\DcaField\DcaAuthorListener; use HeimrichHannot\UtilsBundle\Tests\AbstractUtilsTestCase; use PHPUnit\Framework\MockObject\MockBuilder; +use Psr\Container\ContainerInterface; use Symfony\Component\Security\Core\Security; class DcaAuthorListenerTest extends AbstractUtilsTestCase @@ -18,7 +19,19 @@ public function getTestInstance(array $parameters = [], ?MockBuilder $mockBuilde { $framework = $parameters['framework'] ?? $this->mockContaoFramework(); $security = $parameters['security'] ?? $this->createMock(Security::class); - return new DcaAuthorListener($framework, $security); + + $container = $this->createMock(ContainerInterface::class); + $container->method('get')->willReturnCallback(function ($key) use ($framework, $security) { + switch ($key) { + case 'contao.framework': + return $framework; + case 'security.helper': + return $security; + } + return null; + }); + + return new DcaAuthorListener($container); } public function testOnLoadDataContainer()