diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-07-24 12:48:53 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-24 12:48:53 +0200 |
commit | 204035bd3c91b9a5c39fcb6fc470e108b032dbd9 (patch) | |
tree | b3b3c01bd162da4d0672a7fd3b598d8c4580c980 /tests/front/controller/admin | |
parent | 87ae3c4f08431e02869376cb57add257747910d1 (diff) | |
download | Shaarli-204035bd3c91b9a5c39fcb6fc470e108b032dbd9.tar.gz Shaarli-204035bd3c91b9a5c39fcb6fc470e108b032dbd9.tar.zst Shaarli-204035bd3c91b9a5c39fcb6fc470e108b032dbd9.zip |
Fix: visitor are allowed to chose nb of links per page
Diffstat (limited to 'tests/front/controller/admin')
-rw-r--r-- | tests/front/controller/admin/SessionFilterControllerTest.php | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/tests/front/controller/admin/SessionFilterControllerTest.php b/tests/front/controller/admin/SessionFilterControllerTest.php index ea07edee..124b0bf2 100644 --- a/tests/front/controller/admin/SessionFilterControllerTest.php +++ b/tests/front/controller/admin/SessionFilterControllerTest.php | |||
@@ -23,53 +23,7 @@ class SessionFilterControllerTest extends TestCase | |||
23 | 23 | ||
24 | $this->controller = new SessionFilterController($this->container); | 24 | $this->controller = new SessionFilterController($this->container); |
25 | } | 25 | } |
26 | 26 | ||
27 | /** | ||
28 | * Link per page - Default call with valid parameter and a referer. | ||
29 | */ | ||
30 | public function testLinksPerPage(): void | ||
31 | { | ||
32 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; | ||
33 | |||
34 | $request = $this->createMock(Request::class); | ||
35 | $request->method('getParam')->with('nb')->willReturn('8'); | ||
36 | $response = new Response(); | ||
37 | |||
38 | $this->container->sessionManager | ||
39 | ->expects(static::once()) | ||
40 | ->method('setSessionParameter') | ||
41 | ->with(SessionManager::KEY_LINKS_PER_PAGE, 8) | ||
42 | ; | ||
43 | |||
44 | $result = $this->controller->linksPerPage($request, $response); | ||
45 | |||
46 | static::assertInstanceOf(Response::class, $result); | ||
47 | static::assertSame(302, $result->getStatusCode()); | ||
48 | static::assertSame(['/subfolder/controller/?searchtag=abc'], $result->getHeader('location')); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Link per page - Invalid value, should use default value (20) | ||
53 | */ | ||
54 | public function testLinksPerPageNotValid(): void | ||
55 | { | ||
56 | $request = $this->createMock(Request::class); | ||
57 | $request->method('getParam')->with('nb')->willReturn('test'); | ||
58 | $response = new Response(); | ||
59 | |||
60 | $this->container->sessionManager | ||
61 | ->expects(static::once()) | ||
62 | ->method('setSessionParameter') | ||
63 | ->with(SessionManager::KEY_LINKS_PER_PAGE, 20) | ||
64 | ; | ||
65 | |||
66 | $result = $this->controller->linksPerPage($request, $response); | ||
67 | |||
68 | static::assertInstanceOf(Response::class, $result); | ||
69 | static::assertSame(302, $result->getStatusCode()); | ||
70 | static::assertSame(['/subfolder/'], $result->getHeader('location')); | ||
71 | } | ||
72 | |||
73 | /** | 27 | /** |
74 | * Visibility - Default call for private filter while logged in without current value | 28 | * Visibility - Default call for private filter while logged in without current value |
75 | */ | 29 | */ |