Skip to content

Commit

Permalink
test: add test for baseURL with subfolder
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 12, 2023
1 parent 22bf430 commit d5a6b17
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/system/CommonFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\SiteURI;
use CodeIgniter\HTTP\URI;
use CodeIgniter\HTTP\UserAgent;
use CodeIgniter\Router\RouteCollection;
Expand Down Expand Up @@ -612,6 +613,7 @@ public function testViewNotSaveData(): void
public function testForceHttpsNullRequestAndResponse(): void
{
$this->assertNull(Services::response()->header('Location'));

Services::response()->setCookie('force', 'cookie');
Services::response()->setHeader('Force', 'header');
Services::response()->setBody('default body');
Expand All @@ -634,6 +636,25 @@ public function testForceHttpsNullRequestAndResponse(): void
force_https();
}

public function testForceHttpsWithBaseUrlSubFolder(): void
{
$config = config(App::class);
$config->baseURL = 'https://example.jp/codeIgniter/';
$uri = new SiteURI($config, 'en/home');
$request = new IncomingRequest($config, $uri, '', new UserAgent());
Services::injectMock('request', $request);

try {
force_https();
} catch (Exception $e) {
$this->assertInstanceOf(RedirectException::class, $e);
$this->assertSame(
'https://example.jp/codeIgniter/en/home',
$e->getResponse()->header('Location')->getValue()
);
}
}

/**
* @dataProvider provideCleanPathActuallyCleaningThePaths
*
Expand Down

0 comments on commit d5a6b17

Please sign in to comment.