From b93cfeba7b5ddb8b20d805017404e73eafd68c95 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 3 Sep 2020 14:52:34 +0200 Subject: Fix subfolder configuration in unit tests --- .../controller/visitor/InstallControllerTest.php | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'tests/front/controller/visitor/InstallControllerTest.php') 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 static::assertSame('/subfolder/login', $result->getHeader('location')[0]); static::assertSame('UTC', $confSettings['general.timezone']); - static::assertSame('Shared bookmarks on http://shaarli', $confSettings['general.title']); + static::assertSame('Shared bookmarks on http://shaarli/subfolder/', $confSettings['general.title']); + } + + /** + * Same test as testSaveInstallDefaultValues() but for an instance install in root directory. + */ + public function testSaveInstallDefaultValuesWithoutSubfolder(): void + { + $confSettings = []; + + $this->container->environment = [ + 'SERVER_NAME' => 'shaarli', + 'SERVER_PORT' => '80', + 'REQUEST_URI' => '/install', + 'REMOTE_ADDR' => '1.2.3.4', + 'SCRIPT_NAME' => '/index.php', + ]; + + $this->container->basePath = ''; + + $request = $this->createMock(Request::class); + $response = new Response(); + + $this->container->conf->method('set')->willReturnCallback(function (string $key, $value) use (&$confSettings) { + $confSettings[$key] = $value; + }); + + $result = $this->controller->save($request, $response); + + static::assertSame(302, $result->getStatusCode()); + static::assertSame('/login', $result->getHeader('location')[0]); + + static::assertSame('UTC', $confSettings['general.timezone']); + static::assertSame('Shared bookmarks on http://shaarli/', $confSettings['general.title']); } } -- cgit v1.2.3