diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-09-22 14:08:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 14:08:54 +0200 |
commit | 98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77 (patch) | |
tree | 044721fd02d631f561b9279e5181905a2b1bfa49 /tests/front/controller/visitor | |
parent | 6f199ee48906ca8cdc7d7f2cacbd4c57f474c879 (diff) | |
parent | b93cfeba7b5ddb8b20d805017404e73eafd68c95 (diff) | |
download | Shaarli-98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77.tar.gz Shaarli-98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77.tar.zst Shaarli-98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77.zip |
Merge pull request #1539 from ArthurHoaro/feature/manual-root-url
Diffstat (limited to 'tests/front/controller/visitor')
4 files changed, 43 insertions, 9 deletions
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 927e7f0a..6c53289b 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 | } |