]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/front/controller/admin/LogoutControllerTest.php
Compatibility with PHPUnit 9
[github/shaarli/Shaarli.git] / tests / front / controller / admin / LogoutControllerTest.php
CommitLineData
8e47af2b
A
1<?php
2
3declare(strict_types=1);
4
2899ebb5 5namespace Shaarli\Front\Controller\Admin;
8e47af2b 6
c4ad3d4f 7use Shaarli\Security\CookieManager;
8e47af2b 8use Shaarli\Security\SessionManager;
a5a9cf23 9use Shaarli\TestCase;
8e47af2b
A
10use Slim\Http\Request;
11use Slim\Http\Response;
12
13class LogoutControllerTest extends TestCase
14{
2899ebb5 15 use FrontAdminControllerMockHelper;
8e47af2b
A
16
17 /** @var LogoutController */
18 protected $controller;
19
20 public function setUp(): void
21 {
dd09ec52
A
22 $this->createContainer();
23
8e47af2b 24 $this->controller = new LogoutController($this->container);
8e47af2b
A
25 }
26
27 public function testValidControllerInvoke(): void
28 {
29 $request = $this->createMock(Request::class);
30 $response = new Response();
31
dd09ec52 32 $this->container->pageCacheManager->expects(static::once())->method('invalidateCaches');
8e47af2b 33
dd09ec52
A
34 $this->container->sessionManager = $this->createMock(SessionManager::class);
35 $this->container->sessionManager->expects(static::once())->method('logout');
8e47af2b 36
c4ad3d4f
A
37 $this->container->cookieManager = $this->createMock(CookieManager::class);
38 $this->container->cookieManager
39 ->expects(static::once())
40 ->method('setCookieParameter')
41 ->with(CookieManager::STAY_SIGNED_IN, 'false', 0, '/subfolder/')
42 ;
8e47af2b
A
43
44 $result = $this->controller->index($request, $response);
45
46 static::assertInstanceOf(Response::class, $result);
47 static::assertSame(302, $result->getStatusCode());
9c75f877 48 static::assertSame(['/subfolder/'], $result->getHeader('location'));
8e47af2b
A
49 }
50}