aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/admin
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-06-13 11:22:14 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-23 21:19:21 +0200
commit818b3193ffabec57501e3bdfa997206e3c0671ef (patch)
treef5a4d3cc23ac367dde617b849561177fc20d767a /tests/front/controller/admin
parentc22fa57a5505fe95fd01860e3d3dfbb089f869cd (diff)
downloadShaarli-818b3193ffabec57501e3bdfa997206e3c0671ef.tar.gz
Shaarli-818b3193ffabec57501e3bdfa997206e3c0671ef.tar.zst
Shaarli-818b3193ffabec57501e3bdfa997206e3c0671ef.zip
Explicitly define base and asset path in templates
With the new routes, all pages are not all at the same folder level anymore (e.g. /shaare and /shaare/123), so we can't just use './' everywhere. The most consistent way to handle this is to prefix all path with the proper variable, and handle the actual path in controllers.
Diffstat (limited to 'tests/front/controller/admin')
-rw-r--r--tests/front/controller/admin/PostBookmarkControllerTest.php19
-rw-r--r--tests/front/controller/admin/SessionFilterControllerTest.php60
2 files changed, 2 insertions, 77 deletions
diff --git a/tests/front/controller/admin/PostBookmarkControllerTest.php b/tests/front/controller/admin/PostBookmarkControllerTest.php
index f00a15c9..69673bd2 100644
--- a/tests/front/controller/admin/PostBookmarkControllerTest.php
+++ b/tests/front/controller/admin/PostBookmarkControllerTest.php
@@ -13,7 +13,6 @@ use Shaarli\Security\SessionManager;
13use Shaarli\Thumbnailer; 13use Shaarli\Thumbnailer;
14use Slim\Http\Request; 14use Slim\Http\Request;
15use Slim\Http\Response; 15use Slim\Http\Response;
16use Slim\Http\Uri;
17 16
18class PostBookmarkControllerTest extends TestCase 17class PostBookmarkControllerTest extends TestCase
19{ 18{
@@ -406,12 +405,6 @@ class PostBookmarkControllerTest extends TestCase
406 return $parameters[$key] ?? null; 405 return $parameters[$key] ?? null;
407 }) 406 })
408 ; 407 ;
409 $request->method('getUri')->willReturnCallback(function (): Uri {
410 $uri = $this->createMock(Uri::class);
411 $uri->method('getBasePath')->willReturn('/subfolder');
412
413 return $uri;
414 });
415 $response = new Response(); 408 $response = new Response();
416 409
417 $checkBookmark = function (Bookmark $bookmark) use ($parameters) { 410 $checkBookmark = function (Bookmark $bookmark) use ($parameters) {
@@ -493,12 +486,6 @@ class PostBookmarkControllerTest extends TestCase
493 return $parameters[$key] ?? null; 486 return $parameters[$key] ?? null;
494 }) 487 })
495 ; 488 ;
496 $request->method('getUri')->willReturnCallback(function (): Uri {
497 $uri = $this->createMock(Uri::class);
498 $uri->method('getBasePath')->willReturn('/subfolder');
499
500 return $uri;
501 });
502 $response = new Response(); 489 $response = new Response();
503 490
504 $checkBookmark = function (Bookmark $bookmark) use ($parameters, $id) { 491 $checkBookmark = function (Bookmark $bookmark) use ($parameters, $id) {
@@ -575,12 +562,6 @@ class PostBookmarkControllerTest extends TestCase
575 return $parameters[$key] ?? null; 562 return $parameters[$key] ?? null;
576 }) 563 })
577 ; 564 ;
578 $request->method('getUri')->willReturnCallback(function (): Uri {
579 $uri = $this->createMock(Uri::class);
580 $uri->method('getBasePath')->willReturn('/subfolder');
581
582 return $uri;
583 });
584 $response = new Response(); 565 $response = new Response();
585 566
586 $this->container->conf = $this->createMock(ConfigManager::class); 567 $this->container->conf = $this->createMock(ConfigManager::class);
diff --git a/tests/front/controller/admin/SessionFilterControllerTest.php b/tests/front/controller/admin/SessionFilterControllerTest.php
index 096963cf..ea07edee 100644
--- a/tests/front/controller/admin/SessionFilterControllerTest.php
+++ b/tests/front/controller/admin/SessionFilterControllerTest.php
@@ -9,7 +9,6 @@ use Shaarli\Security\LoginManager;
9use Shaarli\Security\SessionManager; 9use Shaarli\Security\SessionManager;
10use Slim\Http\Request; 10use Slim\Http\Request;
11use Slim\Http\Response; 11use Slim\Http\Response;
12use Slim\Http\Uri;
13 12
14class SessionFilterControllerTest extends TestCase 13class SessionFilterControllerTest extends TestCase
15{ 14{
@@ -33,12 +32,6 @@ class SessionFilterControllerTest extends TestCase
33 $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; 32 $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc'];
34 33
35 $request = $this->createMock(Request::class); 34 $request = $this->createMock(Request::class);
36 $request->method('getUri')->willReturnCallback(function (): Uri {
37 $uri = $this->createMock(Uri::class);
38 $uri->method('getBasePath')->willReturn('/subfolder');
39
40 return $uri;
41 });
42 $request->method('getParam')->with('nb')->willReturn('8'); 35 $request->method('getParam')->with('nb')->willReturn('8');
43 $response = new Response(); 36 $response = new Response();
44 37
@@ -61,12 +54,6 @@ class SessionFilterControllerTest extends TestCase
61 public function testLinksPerPageNotValid(): void 54 public function testLinksPerPageNotValid(): void
62 { 55 {
63 $request = $this->createMock(Request::class); 56 $request = $this->createMock(Request::class);
64 $request->method('getUri')->willReturnCallback(function (): Uri {
65 $uri = $this->createMock(Uri::class);
66 $uri->method('getBasePath')->willReturn('/subfolder');
67
68 return $uri;
69 });
70 $request->method('getParam')->with('nb')->willReturn('test'); 57 $request->method('getParam')->with('nb')->willReturn('test');
71 $response = new Response(); 58 $response = new Response();
72 59
@@ -80,7 +67,7 @@ class SessionFilterControllerTest extends TestCase
80 67
81 static::assertInstanceOf(Response::class, $result); 68 static::assertInstanceOf(Response::class, $result);
82 static::assertSame(302, $result->getStatusCode()); 69 static::assertSame(302, $result->getStatusCode());
83 static::assertSame(['/subfolder'], $result->getHeader('location')); 70 static::assertSame(['/subfolder/'], $result->getHeader('location'));
84 } 71 }
85 72
86 /** 73 /**
@@ -100,12 +87,6 @@ class SessionFilterControllerTest extends TestCase
100 ; 87 ;
101 88
102 $request = $this->createMock(Request::class); 89 $request = $this->createMock(Request::class);
103 $request->method('getUri')->willReturnCallback(function (): Uri {
104 $uri = $this->createMock(Uri::class);
105 $uri->method('getBasePath')->willReturn('/subfolder');
106
107 return $uri;
108 });
109 $response = new Response(); 90 $response = new Response();
110 91
111 $result = $this->controller->visibility($request, $response, $arg); 92 $result = $this->controller->visibility($request, $response, $arg);
@@ -141,12 +122,6 @@ class SessionFilterControllerTest extends TestCase
141 ; 122 ;
142 123
143 $request = $this->createMock(Request::class); 124 $request = $this->createMock(Request::class);
144 $request->method('getUri')->willReturnCallback(function (): Uri {
145 $uri = $this->createMock(Uri::class);
146 $uri->method('getBasePath')->willReturn('/subfolder');
147
148 return $uri;
149 });
150 $response = new Response(); 125 $response = new Response();
151 126
152 $result = $this->controller->visibility($request, $response, $arg); 127 $result = $this->controller->visibility($request, $response, $arg);
@@ -176,19 +151,13 @@ class SessionFilterControllerTest extends TestCase
176 ; 151 ;
177 152
178 $request = $this->createMock(Request::class); 153 $request = $this->createMock(Request::class);
179 $request->method('getUri')->willReturnCallback(function (): Uri {
180 $uri = $this->createMock(Uri::class);
181 $uri->method('getBasePath')->willReturn('/subfolder');
182
183 return $uri;
184 });
185 $response = new Response(); 154 $response = new Response();
186 155
187 $result = $this->controller->visibility($request, $response, $arg); 156 $result = $this->controller->visibility($request, $response, $arg);
188 157
189 static::assertInstanceOf(Response::class, $result); 158 static::assertInstanceOf(Response::class, $result);
190 static::assertSame(302, $result->getStatusCode()); 159 static::assertSame(302, $result->getStatusCode());
191 static::assertSame(['/subfolder'], $result->getHeader('location')); 160 static::assertSame(['/subfolder/'], $result->getHeader('location'));
192 } 161 }
193 162
194 /** 163 /**
@@ -212,12 +181,6 @@ class SessionFilterControllerTest extends TestCase
212 ; 181 ;
213 182
214 $request = $this->createMock(Request::class); 183 $request = $this->createMock(Request::class);
215 $request->method('getUri')->willReturnCallback(function (): Uri {
216 $uri = $this->createMock(Uri::class);
217 $uri->method('getBasePath')->willReturn('/subfolder');
218
219 return $uri;
220 });
221 $response = new Response(); 184 $response = new Response();
222 185
223 $result = $this->controller->visibility($request, $response, $arg); 186 $result = $this->controller->visibility($request, $response, $arg);
@@ -249,12 +212,6 @@ class SessionFilterControllerTest extends TestCase
249 ; 212 ;
250 213
251 $request = $this->createMock(Request::class); 214 $request = $this->createMock(Request::class);
252 $request->method('getUri')->willReturnCallback(function (): Uri {
253 $uri = $this->createMock(Uri::class);
254 $uri->method('getBasePath')->willReturn('/subfolder');
255
256 return $uri;
257 });
258 $response = new Response(); 215 $response = new Response();
259 216
260 $result = $this->controller->visibility($request, $response, $arg); 217 $result = $this->controller->visibility($request, $response, $arg);
@@ -272,12 +229,6 @@ class SessionFilterControllerTest extends TestCase
272 $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; 229 $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc'];
273 230
274 $request = $this->createMock(Request::class); 231 $request = $this->createMock(Request::class);
275 $request->method('getUri')->willReturnCallback(function (): Uri {
276 $uri = $this->createMock(Uri::class);
277 $uri->method('getBasePath')->willReturn('/subfolder');
278
279 return $uri;
280 });
281 $response = new Response(); 232 $response = new Response();
282 233
283 $this->container->sessionManager 234 $this->container->sessionManager
@@ -301,13 +252,6 @@ class SessionFilterControllerTest extends TestCase
301 $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; 252 $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc'];
302 253
303 $request = $this->createMock(Request::class); 254 $request = $this->createMock(Request::class);
304 $request->method('getUri')->willReturnCallback(function (): Uri {
305 $uri = $this->createMock(Uri::class);
306 $uri->method('getBasePath')->willReturn('/subfolder');
307
308 return $uri;
309 });
310
311 $response = new Response(); 255 $response = new Response();
312 256
313 $this->container->sessionManager 257 $this->container->sessionManager