diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-11-12 13:11:07 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-11-12 13:11:07 +0100 |
commit | af50eba28a7bd286de4c8c9ee6dc5216b915d149 (patch) | |
tree | ffa30a9358e82d27be75d8fc5e57f3c8820dc6d3 /tests/front/controller/visitor/ErrorControllerTest.php | |
parent | b6f678a5a1d15acf284ebcec16c905e976671ce1 (diff) | |
parent | 1409f1c89a7ca01456ae2dcd6357d296e2b99f5a (diff) | |
download | Shaarli-af50eba28a7bd286de4c8c9ee6dc5216b915d149.tar.gz Shaarli-af50eba28a7bd286de4c8c9ee6dc5216b915d149.tar.zst Shaarli-af50eba28a7bd286de4c8c9ee6dc5216b915d149.zip |
Merge tag 'v0.12.1' into latestlatest
v0.12.1
Diffstat (limited to 'tests/front/controller/visitor/ErrorControllerTest.php')
-rw-r--r-- | tests/front/controller/visitor/ErrorControllerTest.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/front/controller/visitor/ErrorControllerTest.php b/tests/front/controller/visitor/ErrorControllerTest.php index 75408cf4..e18a6fa2 100644 --- a/tests/front/controller/visitor/ErrorControllerTest.php +++ b/tests/front/controller/visitor/ErrorControllerTest.php | |||
@@ -50,7 +50,31 @@ class ErrorControllerTest extends TestCase | |||
50 | } | 50 | } |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Test displaying error with any exception (no debug): only display an error occurred with HTTP 500. | 53 | * Test displaying error with any exception (no debug) while logged in: |
54 | * display full error details | ||
55 | */ | ||
56 | public function testDisplayAnyExceptionErrorNoDebugLoggedIn(): void | ||
57 | { | ||
58 | $request = $this->createMock(Request::class); | ||
59 | $response = new Response(); | ||
60 | |||
61 | // Save RainTPL assigned variables | ||
62 | $assignedVariables = []; | ||
63 | $this->assignTemplateVars($assignedVariables); | ||
64 | |||
65 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); | ||
66 | |||
67 | $result = ($this->controller)($request, $response, new \Exception('abc')); | ||
68 | |||
69 | static::assertSame(500, $result->getStatusCode()); | ||
70 | static::assertSame('Error: abc', $assignedVariables['message']); | ||
71 | static::assertContainsPolyfill('Please report it on Github', $assignedVariables['text']); | ||
72 | static::assertArrayHasKey('stacktrace', $assignedVariables); | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * Test displaying error with any exception (no debug) while logged out: | ||
77 | * display standard error without detail | ||
54 | */ | 78 | */ |
55 | public function testDisplayAnyExceptionErrorNoDebug(): void | 79 | public function testDisplayAnyExceptionErrorNoDebug(): void |
56 | { | 80 | { |
@@ -61,10 +85,13 @@ class ErrorControllerTest extends TestCase | |||
61 | $assignedVariables = []; | 85 | $assignedVariables = []; |
62 | $this->assignTemplateVars($assignedVariables); | 86 | $this->assignTemplateVars($assignedVariables); |
63 | 87 | ||
88 | $this->container->loginManager->method('isLoggedIn')->willReturn(false); | ||
89 | |||
64 | $result = ($this->controller)($request, $response, new \Exception('abc')); | 90 | $result = ($this->controller)($request, $response, new \Exception('abc')); |
65 | 91 | ||
66 | static::assertSame(500, $result->getStatusCode()); | 92 | static::assertSame(500, $result->getStatusCode()); |
67 | static::assertSame('An unexpected error occurred.', $assignedVariables['message']); | 93 | static::assertSame('An unexpected error occurred.', $assignedVariables['message']); |
94 | static::assertArrayNotHasKey('text', $assignedVariables); | ||
68 | static::assertArrayNotHasKey('stacktrace', $assignedVariables); | 95 | static::assertArrayNotHasKey('stacktrace', $assignedVariables); |
69 | } | 96 | } |
70 | } | 97 | } |