diff options
Diffstat (limited to 'tests/front/controller/admin/FrontAdminControllerMockHelper.php')
-rw-r--r-- | tests/front/controller/admin/FrontAdminControllerMockHelper.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/front/controller/admin/FrontAdminControllerMockHelper.php b/tests/front/controller/admin/FrontAdminControllerMockHelper.php new file mode 100644 index 00000000..94581c09 --- /dev/null +++ b/tests/front/controller/admin/FrontAdminControllerMockHelper.php | |||
@@ -0,0 +1,34 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Shaarli\Front\Controller\Admin; | ||
6 | |||
7 | use Shaarli\Container\ShaarliTestContainer; | ||
8 | use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper; | ||
9 | use Shaarli\Security\LoginManager; | ||
10 | |||
11 | /** | ||
12 | * Trait FrontControllerMockHelper | ||
13 | * | ||
14 | * Helper trait used to initialize the ShaarliContainer and mock its services for admin controller tests. | ||
15 | * | ||
16 | * @property ShaarliTestContainer $container | ||
17 | */ | ||
18 | trait FrontAdminControllerMockHelper | ||
19 | { | ||
20 | use FrontControllerMockHelper { | ||
21 | FrontControllerMockHelper::createContainer as parentCreateContainer; | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * Mock the container instance | ||
26 | */ | ||
27 | protected function createContainer(): void | ||
28 | { | ||
29 | $this->parentCreateContainer(); | ||
30 | |||
31 | $this->container->loginManager = $this->createMock(LoginManager::class); | ||
32 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); | ||
33 | } | ||
34 | } | ||