-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathStatusControllerTest.php
More file actions
87 lines (72 loc) · 2.83 KB
/
Copy pathStatusControllerTest.php
File metadata and controls
87 lines (72 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
* Copyright (c) 2025-2026 Netresearch DTT GmbH
* SPDX-License-Identifier: AGPL-3.0-only
*/
declare(strict_types=1);
namespace Tests\Controller;
use Tests\AbstractWebTestCase;
use Tests\Traits\HttpRequestTestTrait;
/**
* @internal
*
* @coversNothing
*/
final class StatusControllerTest extends AbstractWebTestCase
{
use HttpRequestTestTrait;
public function testCheckAction(): void
{
$expectedJson = [
'loginStatus' => true,
];
$this->getJson('/status/check');
$this->assertStatusCode(200);
$this->assertJsonStructure($expectedJson, $this->getJsonResponse($this->client->getResponse()));
}
public function testPageAction(): void
{
$this->get('/status/page');
$this->assertStatusCode(200);
// Check that the response contains valid HTML
$response = $this->client->getResponse();
$content = $response->getContent();
// Just verify we got HTML with expected content
self::assertStringContainsString('<!DOCTYPE HTML>', (string) $content);
self::assertStringContainsString('<html>', (string) $content);
self::assertStringContainsString('Login-Status', (string) $content);
self::assertStringContainsString('class="status_active"', (string) $content);
}
public function testPageActionWithLoggedInUserReturnsActiveStatus(): void
{
$this->get('/status/page');
$this->assertStatusCode(200);
self::assertStringContainsString('class="status_active"', (string) $this->client->getResponse()->getContent());
}
public function testPageActionWithLoggedOutUserReturnsInactiveStatus(): void
{
self::ensureKernelShutdown();
$this->client = self::createClient();
$this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/status/page');
$this->assertStatusCode(200);
self::assertStringContainsString('class="status_inactive"', (string) $this->client->getResponse()->getContent());
}
public function testCheckActionWithLoggedInUserReturnsActiveStatus(): void
{
$this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/status/check');
$this->assertStatusCode(200);
$this->assertJsonStructure([
'loginStatus' => true,
], $this->getJsonResponse($this->client->getResponse()));
}
public function testCheckActionWithLoggedOutUserReturnsInactiveStatus(): void
{
self::ensureKernelShutdown();
$this->client = self::createClient();
$this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/status/check');
$this->assertStatusCode(200);
$this->assertJsonStructure([
'loginStatus' => false,
], $this->getJsonResponse($this->client->getResponse()));
}
}