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