3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller\Admin
;
7 use Shaarli\Security\CookieManager
;
8 use Shaarli\Security\SessionManager
;
10 use Slim\Http\Request
;
11 use Slim\Http\Response
;
13 class LogoutControllerTest
extends TestCase
15 use FrontAdminControllerMockHelper
;
17 /** @var LogoutController */
18 protected $controller;
20 public function setUp(): void
22 $this->createContainer();
24 $this->controller
= new LogoutController($this->container
);
27 public function testValidControllerInvoke(): void
29 $request = $this->createMock(Request
::class);
30 $response = new Response();
32 $this->container
->pageCacheManager
->expects(static::once())->method('invalidateCaches');
34 $this->container
->sessionManager
= $this->createMock(SessionManager
::class);
35 $this->container
->sessionManager
->expects(static::once())->method('logout');
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/')
44 $result = $this->controller
->index($request, $response);
46 static::assertInstanceOf(Response
::class, $result);
47 static::assertSame(302, $result->getStatusCode());
48 static::assertSame(['/subfolder/'], $result->getHeader('location'));