diff options
Diffstat (limited to 'tests/front/controller/LogoutControllerTest.php')
-rw-r--r-- | tests/front/controller/LogoutControllerTest.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/tests/front/controller/LogoutControllerTest.php b/tests/front/controller/LogoutControllerTest.php index d9ca1c25..8e01c367 100644 --- a/tests/front/controller/LogoutControllerTest.php +++ b/tests/front/controller/LogoutControllerTest.php | |||
@@ -12,8 +12,6 @@ if (!function_exists('Shaarli\Front\Controller\setcookie')) { | |||
12 | } | 12 | } |
13 | 13 | ||
14 | use PHPUnit\Framework\TestCase; | 14 | use PHPUnit\Framework\TestCase; |
15 | use Shaarli\Container\ShaarliContainer; | ||
16 | use Shaarli\Render\PageCacheManager; | ||
17 | use Shaarli\Security\LoginManager; | 15 | use Shaarli\Security\LoginManager; |
18 | use Shaarli\Security\SessionManager; | 16 | use Shaarli\Security\SessionManager; |
19 | use Slim\Http\Request; | 17 | use Slim\Http\Request; |
@@ -21,15 +19,15 @@ use Slim\Http\Response; | |||
21 | 19 | ||
22 | class LogoutControllerTest extends TestCase | 20 | class LogoutControllerTest extends TestCase |
23 | { | 21 | { |
24 | /** @var ShaarliContainer */ | 22 | use FrontControllerMockHelper; |
25 | protected $container; | ||
26 | 23 | ||
27 | /** @var LogoutController */ | 24 | /** @var LogoutController */ |
28 | protected $controller; | 25 | protected $controller; |
29 | 26 | ||
30 | public function setUp(): void | 27 | public function setUp(): void |
31 | { | 28 | { |
32 | $this->container = $this->createMock(ShaarliContainer::class); | 29 | $this->createContainer(); |
30 | |||
33 | $this->controller = new LogoutController($this->container); | 31 | $this->controller = new LogoutController($this->container); |
34 | 32 | ||
35 | setcookie(LoginManager::$STAY_SIGNED_IN_COOKIE, $cookie = 'hi there'); | 33 | setcookie(LoginManager::$STAY_SIGNED_IN_COOKIE, $cookie = 'hi there'); |
@@ -37,16 +35,15 @@ class LogoutControllerTest extends TestCase | |||
37 | 35 | ||
38 | public function testValidControllerInvoke(): void | 36 | public function testValidControllerInvoke(): void |
39 | { | 37 | { |
38 | $this->createValidContainerMockSet(); | ||
39 | |||
40 | $request = $this->createMock(Request::class); | 40 | $request = $this->createMock(Request::class); |
41 | $response = new Response(); | 41 | $response = new Response(); |
42 | 42 | ||
43 | $pageCacheManager = $this->createMock(PageCacheManager::class); | 43 | $this->container->pageCacheManager->expects(static::once())->method('invalidateCaches'); |
44 | $pageCacheManager->expects(static::once())->method('invalidateCaches'); | ||
45 | $this->container->pageCacheManager = $pageCacheManager; | ||
46 | 44 | ||
47 | $sessionManager = $this->createMock(SessionManager::class); | 45 | $this->container->sessionManager = $this->createMock(SessionManager::class); |
48 | $sessionManager->expects(static::once())->method('logout'); | 46 | $this->container->sessionManager->expects(static::once())->method('logout'); |
49 | $this->container->sessionManager = $sessionManager; | ||
50 | 47 | ||
51 | static::assertSame('hi there', $_COOKIE[LoginManager::$STAY_SIGNED_IN_COOKIE]); | 48 | static::assertSame('hi there', $_COOKIE[LoginManager::$STAY_SIGNED_IN_COOKIE]); |
52 | 49 | ||