Skip to content

Commit d5a6b17

Browse files
committed
test: add test for baseURL with subfolder
1 parent 22bf430 commit d5a6b17

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/system/CommonFunctionsTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use CodeIgniter\HTTP\IncomingRequest;
1919
use CodeIgniter\HTTP\RedirectResponse;
2020
use CodeIgniter\HTTP\Response;
21+
use CodeIgniter\HTTP\SiteURI;
2122
use CodeIgniter\HTTP\URI;
2223
use CodeIgniter\HTTP\UserAgent;
2324
use CodeIgniter\Router\RouteCollection;
@@ -612,6 +613,7 @@ public function testViewNotSaveData(): void
612613
public function testForceHttpsNullRequestAndResponse(): void
613614
{
614615
$this->assertNull(Services::response()->header('Location'));
616+
615617
Services::response()->setCookie('force', 'cookie');
616618
Services::response()->setHeader('Force', 'header');
617619
Services::response()->setBody('default body');
@@ -634,6 +636,25 @@ public function testForceHttpsNullRequestAndResponse(): void
634636
force_https();
635637
}
636638

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

0 commit comments

Comments
 (0)