diff options
Diffstat (limited to 'tests/front')
6 files changed, 47 insertions, 13 deletions
diff --git a/tests/front/controller/admin/ExportControllerTest.php b/tests/front/controller/admin/ExportControllerTest.php index 50d9e378..12d26f4a 100644 --- a/tests/front/controller/admin/ExportControllerTest.php +++ b/tests/front/controller/admin/ExportControllerTest.php | |||
@@ -84,7 +84,7 @@ class ExportControllerTest extends TestCase | |||
84 | static::assertInstanceOf(BookmarkRawFormatter::class, $formatter); | 84 | static::assertInstanceOf(BookmarkRawFormatter::class, $formatter); |
85 | static::assertSame($parameters['selection'], $selection); | 85 | static::assertSame($parameters['selection'], $selection); |
86 | static::assertTrue($prependNoteUrl); | 86 | static::assertTrue($prependNoteUrl); |
87 | static::assertSame('http://shaarli', $indexUrl); | 87 | static::assertSame('http://shaarli/subfolder/', $indexUrl); |
88 | 88 | ||
89 | return $bookmarks; | 89 | return $bookmarks; |
90 | } | 90 | } |
diff --git a/tests/front/controller/admin/ToolsControllerTest.php b/tests/front/controller/admin/ToolsControllerTest.php index fc756f0f..39144d2f 100644 --- a/tests/front/controller/admin/ToolsControllerTest.php +++ b/tests/front/controller/admin/ToolsControllerTest.php | |||
@@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; | |||
8 | use Slim\Http\Request; | 8 | use Slim\Http\Request; |
9 | use Slim\Http\Response; | 9 | use Slim\Http\Response; |
10 | 10 | ||
11 | class ToolsControllerTestControllerTest extends TestCase | 11 | class ToolsControllerTest extends TestCase |
12 | { | 12 | { |
13 | use FrontAdminControllerMockHelper; | 13 | use FrontAdminControllerMockHelper; |
14 | 14 | ||
@@ -41,7 +41,7 @@ class ToolsControllerTestControllerTest extends TestCase | |||
41 | 41 | ||
42 | static::assertSame(200, $result->getStatusCode()); | 42 | static::assertSame(200, $result->getStatusCode()); |
43 | static::assertSame('tools', (string) $result->getBody()); | 43 | static::assertSame('tools', (string) $result->getBody()); |
44 | static::assertSame('https://shaarli', $assignedVariables['pageabsaddr']); | 44 | static::assertSame('https://shaarli/', $assignedVariables['pageabsaddr']); |
45 | static::assertTrue($assignedVariables['sslenabled']); | 45 | static::assertTrue($assignedVariables['sslenabled']); |
46 | } | 46 | } |
47 | 47 | ||
@@ -63,7 +63,7 @@ class ToolsControllerTestControllerTest extends TestCase | |||
63 | 63 | ||
64 | static::assertSame(200, $result->getStatusCode()); | 64 | static::assertSame(200, $result->getStatusCode()); |
65 | static::assertSame('tools', (string) $result->getBody()); | 65 | static::assertSame('tools', (string) $result->getBody()); |
66 | static::assertSame('http://shaarli', $assignedVariables['pageabsaddr']); | 66 | static::assertSame('http://shaarli/', $assignedVariables['pageabsaddr']); |
67 | static::assertFalse($assignedVariables['sslenabled']); | 67 | static::assertFalse($assignedVariables['sslenabled']); |
68 | } | 68 | } |
69 | } | 69 | } |
diff --git a/tests/front/controller/visitor/DailyControllerTest.php b/tests/front/controller/visitor/DailyControllerTest.php index b802c62c..cb5b96f3 100644 --- a/tests/front/controller/visitor/DailyControllerTest.php +++ b/tests/front/controller/visitor/DailyControllerTest.php | |||
@@ -392,8 +392,8 @@ class DailyControllerTest extends TestCase | |||
392 | static::assertStringContainsString('application/rss', $result->getHeader('Content-Type')[0]); | 392 | static::assertStringContainsString('application/rss', $result->getHeader('Content-Type')[0]); |
393 | static::assertSame('dailyrss', (string) $result->getBody()); | 393 | static::assertSame('dailyrss', (string) $result->getBody()); |
394 | static::assertSame('Shaarli', $assignedVariables['title']); | 394 | static::assertSame('Shaarli', $assignedVariables['title']); |
395 | static::assertSame('http://shaarli', $assignedVariables['index_url']); | 395 | static::assertSame('http://shaarli/subfolder/', $assignedVariables['index_url']); |
396 | static::assertSame('http://shaarli/daily-rss', $assignedVariables['page_url']); | 396 | static::assertSame('http://shaarli/subfolder/daily-rss', $assignedVariables['page_url']); |
397 | static::assertFalse($assignedVariables['hide_timestamps']); | 397 | static::assertFalse($assignedVariables['hide_timestamps']); |
398 | static::assertCount(2, $assignedVariables['days']); | 398 | static::assertCount(2, $assignedVariables['days']); |
399 | 399 | ||
@@ -402,7 +402,7 @@ class DailyControllerTest extends TestCase | |||
402 | static::assertEquals($dates[0], $day['date']); | 402 | static::assertEquals($dates[0], $day['date']); |
403 | static::assertSame($dates[0]->format(\DateTime::RSS), $day['date_rss']); | 403 | static::assertSame($dates[0]->format(\DateTime::RSS), $day['date_rss']); |
404 | static::assertSame(format_date($dates[0], false), $day['date_human']); | 404 | static::assertSame(format_date($dates[0], false), $day['date_human']); |
405 | static::assertSame('http://shaarli/daily?day='. $dates[0]->format('Ymd'), $day['absolute_url']); | 405 | static::assertSame('http://shaarli/subfolder/daily?day='. $dates[0]->format('Ymd'), $day['absolute_url']); |
406 | static::assertCount(1, $day['links']); | 406 | static::assertCount(1, $day['links']); |
407 | static::assertSame(1, $day['links'][0]['id']); | 407 | static::assertSame(1, $day['links'][0]['id']); |
408 | static::assertSame('http://domain.tld/1', $day['links'][0]['url']); | 408 | static::assertSame('http://domain.tld/1', $day['links'][0]['url']); |
@@ -413,7 +413,7 @@ class DailyControllerTest extends TestCase | |||
413 | static::assertEquals($dates[1], $day['date']); | 413 | static::assertEquals($dates[1], $day['date']); |
414 | static::assertSame($dates[1]->format(\DateTime::RSS), $day['date_rss']); | 414 | static::assertSame($dates[1]->format(\DateTime::RSS), $day['date_rss']); |
415 | static::assertSame(format_date($dates[1], false), $day['date_human']); | 415 | static::assertSame(format_date($dates[1], false), $day['date_human']); |
416 | static::assertSame('http://shaarli/daily?day='. $dates[1]->format('Ymd'), $day['absolute_url']); | 416 | static::assertSame('http://shaarli/subfolder/daily?day='. $dates[1]->format('Ymd'), $day['absolute_url']); |
417 | static::assertCount(2, $day['links']); | 417 | static::assertCount(2, $day['links']); |
418 | 418 | ||
419 | static::assertSame(2, $day['links'][0]['id']); | 419 | static::assertSame(2, $day['links'][0]['id']); |
@@ -468,8 +468,8 @@ class DailyControllerTest extends TestCase | |||
468 | static::assertStringContainsString('application/rss', $result->getHeader('Content-Type')[0]); | 468 | static::assertStringContainsString('application/rss', $result->getHeader('Content-Type')[0]); |
469 | static::assertSame('dailyrss', (string) $result->getBody()); | 469 | static::assertSame('dailyrss', (string) $result->getBody()); |
470 | static::assertSame('Shaarli', $assignedVariables['title']); | 470 | static::assertSame('Shaarli', $assignedVariables['title']); |
471 | static::assertSame('http://shaarli', $assignedVariables['index_url']); | 471 | static::assertSame('http://shaarli/subfolder/', $assignedVariables['index_url']); |
472 | static::assertSame('http://shaarli/daily-rss', $assignedVariables['page_url']); | 472 | static::assertSame('http://shaarli/subfolder/daily-rss', $assignedVariables['page_url']); |
473 | static::assertFalse($assignedVariables['hide_timestamps']); | 473 | static::assertFalse($assignedVariables['hide_timestamps']); |
474 | static::assertCount(0, $assignedVariables['days']); | 474 | static::assertCount(0, $assignedVariables['days']); |
475 | } | 475 | } |
diff --git a/tests/front/controller/visitor/FrontControllerMockHelper.php b/tests/front/controller/visitor/FrontControllerMockHelper.php index e0bd4ecf..fe6ac9b0 100644 --- a/tests/front/controller/visitor/FrontControllerMockHelper.php +++ b/tests/front/controller/visitor/FrontControllerMockHelper.php | |||
@@ -79,8 +79,9 @@ trait FrontControllerMockHelper | |||
79 | $this->container->environment = [ | 79 | $this->container->environment = [ |
80 | 'SERVER_NAME' => 'shaarli', | 80 | 'SERVER_NAME' => 'shaarli', |
81 | 'SERVER_PORT' => '80', | 81 | 'SERVER_PORT' => '80', |
82 | 'REQUEST_URI' => '/daily-rss', | 82 | 'REQUEST_URI' => '/subfolder/daily-rss', |
83 | 'REMOTE_ADDR' => '1.2.3.4', | 83 | 'REMOTE_ADDR' => '1.2.3.4', |
84 | 'SCRIPT_NAME' => '/subfolder/index.php', | ||
84 | ]; | 85 | ]; |
85 | 86 | ||
86 | $this->container->basePath = '/subfolder'; | 87 | $this->container->basePath = '/subfolder'; |
diff --git a/tests/front/controller/visitor/InstallControllerTest.php b/tests/front/controller/visitor/InstallControllerTest.php index 3b855365..994d3f33 100644 --- a/tests/front/controller/visitor/InstallControllerTest.php +++ b/tests/front/controller/visitor/InstallControllerTest.php | |||
@@ -257,6 +257,39 @@ class InstallControllerTest extends TestCase | |||
257 | static::assertSame('/subfolder/login', $result->getHeader('location')[0]); | 257 | static::assertSame('/subfolder/login', $result->getHeader('location')[0]); |
258 | 258 | ||
259 | static::assertSame('UTC', $confSettings['general.timezone']); | 259 | static::assertSame('UTC', $confSettings['general.timezone']); |
260 | static::assertSame('Shared bookmarks on http://shaarli', $confSettings['general.title']); | 260 | static::assertSame('Shared bookmarks on http://shaarli/subfolder/', $confSettings['general.title']); |
261 | } | ||
262 | |||
263 | /** | ||
264 | * Same test as testSaveInstallDefaultValues() but for an instance install in root directory. | ||
265 | */ | ||
266 | public function testSaveInstallDefaultValuesWithoutSubfolder(): void | ||
267 | { | ||
268 | $confSettings = []; | ||
269 | |||
270 | $this->container->environment = [ | ||
271 | 'SERVER_NAME' => 'shaarli', | ||
272 | 'SERVER_PORT' => '80', | ||
273 | 'REQUEST_URI' => '/install', | ||
274 | 'REMOTE_ADDR' => '1.2.3.4', | ||
275 | 'SCRIPT_NAME' => '/index.php', | ||
276 | ]; | ||
277 | |||
278 | $this->container->basePath = ''; | ||
279 | |||
280 | $request = $this->createMock(Request::class); | ||
281 | $response = new Response(); | ||
282 | |||
283 | $this->container->conf->method('set')->willReturnCallback(function (string $key, $value) use (&$confSettings) { | ||
284 | $confSettings[$key] = $value; | ||
285 | }); | ||
286 | |||
287 | $result = $this->controller->save($request, $response); | ||
288 | |||
289 | static::assertSame(302, $result->getStatusCode()); | ||
290 | static::assertSame('/login', $result->getHeader('location')[0]); | ||
291 | |||
292 | static::assertSame('UTC', $confSettings['general.timezone']); | ||
293 | static::assertSame('Shared bookmarks on http://shaarli/', $confSettings['general.title']); | ||
261 | } | 294 | } |
262 | } | 295 | } |
diff --git a/tests/front/controller/visitor/OpenSearchControllerTest.php b/tests/front/controller/visitor/OpenSearchControllerTest.php index 5f9f5b12..9609a377 100644 --- a/tests/front/controller/visitor/OpenSearchControllerTest.php +++ b/tests/front/controller/visitor/OpenSearchControllerTest.php | |||
@@ -39,6 +39,6 @@ class OpenSearchControllerTest extends TestCase | |||
39 | $result->getHeader('Content-Type')[0] | 39 | $result->getHeader('Content-Type')[0] |
40 | ); | 40 | ); |
41 | static::assertSame('opensearch', (string) $result->getBody()); | 41 | static::assertSame('opensearch', (string) $result->getBody()); |
42 | static::assertSame('http://shaarli', $assignedVariables['serverurl']); | 42 | static::assertSame('http://shaarli/subfolder/', $assignedVariables['serverurl']); |
43 | } | 43 | } |
44 | } | 44 | } |