3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller\Admin
;
7 use Shaarli\Container\ShaarliTestContainer
;
8 use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper
;
12 * Trait FrontControllerMockHelper
14 * Helper trait used to initialize the ShaarliContainer and mock its services for admin controller tests.
16 * @property ShaarliTestContainer $container
18 trait FrontAdminControllerMockHelper
20 use FrontControllerMockHelper
{
21 FrontControllerMockHelper
::createContainer
as parentCreateContainer
;
25 * Mock the container instance
27 protected function createContainer(): void
29 $this->parentCreateContainer();
31 $this->container
->history
= $this->createMock(History
::class);
33 $this->container
->loginManager
->method('isLoggedIn')->willReturn(true);
34 $this->container
->sessionManager
->method('checkToken')->willReturn(true);
39 * Pass a reference of an array which will be populated by `sessionManager->setSessionParameter`
40 * calls during execution.
42 * @param mixed $variables Array reference to populate.
44 protected function assignSessionVars(array &$variables): void
46 $this->container
->sessionManager
47 ->expects(static::atLeastOnce())
48 ->method('setSessionParameter')
49 ->willReturnCallback(function ($key, $value) use (&$variables) {
50 $variables[$key] = $value;
52 return $this->container
->sessionManager
;