aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-06-21 12:21:31 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-23 21:19:21 +0200
commit764d34a7d347d653414e5f5c632e02499edaef04 (patch)
tree1e642a893beefd95bfa82c7beeb416449238b4ec /tests/front
parent1b8620b1ad4e2c647ff2d032c8e7c6687b6647a1 (diff)
downloadShaarli-764d34a7d347d653414e5f5c632e02499edaef04.tar.gz
Shaarli-764d34a7d347d653414e5f5c632e02499edaef04.tar.zst
Shaarli-764d34a7d347d653414e5f5c632e02499edaef04.zip
Process token retrieve through Slim controller
Diffstat (limited to 'tests/front')
-rw-r--r--tests/front/controller/admin/TokenControllerTest.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/front/controller/admin/TokenControllerTest.php b/tests/front/controller/admin/TokenControllerTest.php
new file mode 100644
index 00000000..04b0c0fa
--- /dev/null
+++ b/tests/front/controller/admin/TokenControllerTest.php
@@ -0,0 +1,41 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Front\Controller\Admin;
6
7use PHPUnit\Framework\TestCase;
8use Slim\Http\Request;
9use Slim\Http\Response;
10
11class TokenControllerTest extends TestCase
12{
13 use FrontAdminControllerMockHelper;
14
15 /** @var TokenController */
16 protected $controller;
17
18 public function setUp(): void
19 {
20 $this->createContainer();
21
22 $this->controller = new TokenController($this->container);
23 }
24
25 public function testGetToken(): void
26 {
27 $request = $this->createMock(Request::class);
28 $response = new Response();
29
30 $this->container->sessionManager
31 ->expects(static::once())
32 ->method('generateToken')
33 ->willReturn($token = 'token1234')
34 ;
35
36 $result = $this->controller->getToken($request, $response);
37
38 static::assertSame(200, $result->getStatusCode());
39 static::assertSame($token, (string) $result->getBody());
40 }
41}