Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Apr 11, 2024
1 parent 5164e3e commit 79e0b51
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/EventListener/DcaField/DcaAuthorListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 79e0b51

Please sign in to comment.