18
18
use CodeIgniter \HTTP \IncomingRequest ;
19
19
use CodeIgniter \HTTP \RedirectResponse ;
20
20
use CodeIgniter \HTTP \Response ;
21
+ use CodeIgniter \HTTP \SiteURI ;
21
22
use CodeIgniter \HTTP \URI ;
22
23
use CodeIgniter \HTTP \UserAgent ;
23
24
use CodeIgniter \Router \RouteCollection ;
@@ -612,6 +613,7 @@ public function testViewNotSaveData(): void
612
613
public function testForceHttpsNullRequestAndResponse (): void
613
614
{
614
615
$ this ->assertNull (Services::response ()->header ('Location ' ));
616
+
615
617
Services::response ()->setCookie ('force ' , 'cookie ' );
616
618
Services::response ()->setHeader ('Force ' , 'header ' );
617
619
Services::response ()->setBody ('default body ' );
@@ -634,6 +636,25 @@ public function testForceHttpsNullRequestAndResponse(): void
634
636
force_https ();
635
637
}
636
638
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
+
637
658
/**
638
659
* @dataProvider provideCleanPathActuallyCleaningThePaths
639
660
*
0 commit comments