diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-13 12:05:08 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-13 12:05:08 +0200 |
commit | b6f678a5a1d15acf284ebcec16c905e976671ce1 (patch) | |
tree | 33c7da831482ed79c44896ef19c73c72ada84f2e /tests/front/controller/admin/LogoutControllerTest.php | |
parent | b14687036b9b800681197f51fdc47e62f0c88e2e (diff) | |
parent | 1c1520b6b98ab20201bfe15577782a52320339df (diff) | |
download | Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.gz Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.zst Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.zip |
Merge branch 'v0.12' into latest
Diffstat (limited to 'tests/front/controller/admin/LogoutControllerTest.php')
-rw-r--r-- | tests/front/controller/admin/LogoutControllerTest.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/front/controller/admin/LogoutControllerTest.php b/tests/front/controller/admin/LogoutControllerTest.php new file mode 100644 index 00000000..94e53019 --- /dev/null +++ b/tests/front/controller/admin/LogoutControllerTest.php | |||
@@ -0,0 +1,50 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Shaarli\Front\Controller\Admin; | ||
6 | |||
7 | use Shaarli\Security\CookieManager; | ||
8 | use Shaarli\Security\SessionManager; | ||
9 | use Shaarli\TestCase; | ||
10 | use Slim\Http\Request; | ||
11 | use Slim\Http\Response; | ||
12 | |||
13 | class LogoutControllerTest extends TestCase | ||
14 | { | ||
15 | use FrontAdminControllerMockHelper; | ||
16 | |||
17 | /** @var LogoutController */ | ||
18 | protected $controller; | ||
19 | |||
20 | public function setUp(): void | ||
21 | { | ||
22 | $this->createContainer(); | ||
23 | |||
24 | $this->controller = new LogoutController($this->container); | ||
25 | } | ||
26 | |||
27 | public function testValidControllerInvoke(): void | ||
28 | { | ||
29 | $request = $this->createMock(Request::class); | ||
30 | $response = new Response(); | ||
31 | |||
32 | $this->container->pageCacheManager->expects(static::once())->method('invalidateCaches'); | ||
33 | |||
34 | $this->container->sessionManager = $this->createMock(SessionManager::class); | ||
35 | $this->container->sessionManager->expects(static::once())->method('logout'); | ||
36 | |||
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 | ; | ||
43 | |||
44 | $result = $this->controller->index($request, $response); | ||
45 | |||
46 | static::assertInstanceOf(Response::class, $result); | ||
47 | static::assertSame(302, $result->getStatusCode()); | ||
48 | static::assertSame(['/subfolder/'], $result->getHeader('location')); | ||
49 | } | ||
50 | } | ||