]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | declare(strict_types=1); | |
4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | |
6 | ||
7 | use PHPUnit\Framework\TestCase; | |
8 | use Slim\Http\Request; | |
9 | use Slim\Http\Response; | |
10 | ||
11 | class 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 | } |