diff options
Diffstat (limited to 'tests/front/controller/admin')
-rw-r--r-- | tests/front/controller/admin/SessionFilterControllerTest.php | 51 | ||||
-rw-r--r-- | tests/front/controller/admin/ShaarliAdminControllerTest.php | 15 |
2 files changed, 0 insertions, 66 deletions
diff --git a/tests/front/controller/admin/SessionFilterControllerTest.php b/tests/front/controller/admin/SessionFilterControllerTest.php index 7d5511ed..d306c6e9 100644 --- a/tests/front/controller/admin/SessionFilterControllerTest.php +++ b/tests/front/controller/admin/SessionFilterControllerTest.php | |||
@@ -174,55 +174,4 @@ class SessionFilterControllerTest extends TestCase | |||
174 | static::assertSame(302, $result->getStatusCode()); | 174 | static::assertSame(302, $result->getStatusCode()); |
175 | static::assertSame(['/subfolder/controller/?searchtag=abc'], $result->getHeader('location')); | 175 | static::assertSame(['/subfolder/controller/?searchtag=abc'], $result->getHeader('location')); |
176 | } | 176 | } |
177 | |||
178 | /** | ||
179 | * Untagged only - valid call | ||
180 | */ | ||
181 | public function testUntaggedOnly(): void | ||
182 | { | ||
183 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; | ||
184 | |||
185 | $request = $this->createMock(Request::class); | ||
186 | $response = new Response(); | ||
187 | |||
188 | $this->container->sessionManager | ||
189 | ->expects(static::once()) | ||
190 | ->method('setSessionParameter') | ||
191 | ->with(SessionManager::KEY_UNTAGGED_ONLY, true) | ||
192 | ; | ||
193 | |||
194 | $result = $this->controller->untaggedOnly($request, $response); | ||
195 | |||
196 | static::assertInstanceOf(Response::class, $result); | ||
197 | static::assertSame(302, $result->getStatusCode()); | ||
198 | static::assertSame(['/subfolder/controller/?searchtag=abc'], $result->getHeader('location')); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Untagged only - toggle off | ||
203 | */ | ||
204 | public function testUntaggedOnlyToggleOff(): void | ||
205 | { | ||
206 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; | ||
207 | |||
208 | $request = $this->createMock(Request::class); | ||
209 | $response = new Response(); | ||
210 | |||
211 | $this->container->sessionManager | ||
212 | ->method('getSessionParameter') | ||
213 | ->with(SessionManager::KEY_UNTAGGED_ONLY) | ||
214 | ->willReturn(true) | ||
215 | ; | ||
216 | $this->container->sessionManager | ||
217 | ->expects(static::once()) | ||
218 | ->method('setSessionParameter') | ||
219 | ->with(SessionManager::KEY_UNTAGGED_ONLY, false) | ||
220 | ; | ||
221 | |||
222 | $result = $this->controller->untaggedOnly($request, $response); | ||
223 | |||
224 | static::assertInstanceOf(Response::class, $result); | ||
225 | static::assertSame(302, $result->getStatusCode()); | ||
226 | static::assertSame(['/subfolder/controller/?searchtag=abc'], $result->getHeader('location')); | ||
227 | } | ||
228 | } | 177 | } |
diff --git a/tests/front/controller/admin/ShaarliAdminControllerTest.php b/tests/front/controller/admin/ShaarliAdminControllerTest.php index 7c5f50a6..fff427cb 100644 --- a/tests/front/controller/admin/ShaarliAdminControllerTest.php +++ b/tests/front/controller/admin/ShaarliAdminControllerTest.php | |||
@@ -5,9 +5,7 @@ declare(strict_types=1); | |||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | 7 | use PHPUnit\Framework\TestCase; |
8 | use Shaarli\Front\Exception\UnauthorizedException; | ||
9 | use Shaarli\Front\Exception\WrongTokenException; | 8 | use Shaarli\Front\Exception\WrongTokenException; |
10 | use Shaarli\Security\LoginManager; | ||
11 | use Shaarli\Security\SessionManager; | 9 | use Shaarli\Security\SessionManager; |
12 | use Slim\Http\Request; | 10 | use Slim\Http\Request; |
13 | 11 | ||
@@ -53,19 +51,6 @@ class ShaarliAdminControllerTest extends TestCase | |||
53 | } | 51 | } |
54 | 52 | ||
55 | /** | 53 | /** |
56 | * Creating an instance of an admin controller while logged out should raise an exception. | ||
57 | */ | ||
58 | public function testInstantiateWhileLoggedOut(): void | ||
59 | { | ||
60 | $this->expectException(UnauthorizedException::class); | ||
61 | |||
62 | $this->container->loginManager = $this->createMock(LoginManager::class); | ||
63 | $this->container->loginManager->method('isLoggedIn')->willReturn(false); | ||
64 | |||
65 | $this->controller = new class($this->container) extends ShaarliAdminController {}; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Trigger controller's checkToken with a valid token. | 54 | * Trigger controller's checkToken with a valid token. |
70 | */ | 55 | */ |
71 | public function testCheckTokenWithValidToken(): void | 56 | public function testCheckTokenWithValidToken(): void |