Skip to content

Commit e56e460

Browse files
committed
test: add test for baseURL with subfolder
1 parent d558616 commit e56e460

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/system/CommonFunctionsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ public function testViewNotSaveData(): void
612612
public function testForceHttpsNullRequestAndResponse(): void
613613
{
614614
$this->assertNull(Services::response()->header('Location'));
615+
615616
Services::response()->setCookie('force', 'cookie');
616617
Services::response()->setHeader('Force', 'header');
617618
Services::response()->setBody('default body');
@@ -634,6 +635,25 @@ public function testForceHttpsNullRequestAndResponse(): void
634635
force_https();
635636
}
636637

638+
public function testForceHttpsWithBaseUrlSubFolder(): void
639+
{
640+
$config = config(App::class);
641+
$config->baseURL = 'https://example.jp/codeIgniter/';
642+
$uri = new SiteURI($config, 'en/home?foo=bar');
643+
$request = new IncomingRequest($config, $uri, '', new UserAgent());
644+
Services::injectMock('request', $request);
645+
646+
try {
647+
force_https();
648+
} catch (Exception $e) {
649+
$this->assertInstanceOf(RedirectException::class, $e);
650+
$this->assertSame(
651+
'https://example.jp/codeIgniter/index.php/en/home?foo=bar',
652+
$e->getResponse()->header('Location')->getValue()
653+
);
654+
}
655+
}
656+
637657
/**
638658
* @dataProvider provideCleanPathActuallyCleaningThePaths
639659
*

0 commit comments

Comments
 (0)