@@ -96,6 +96,7 @@ public function testRunClosureRoute()
9696 $ _SERVER ['argc ' ] = 2 ;
9797
9898 $ _SERVER ['REQUEST_URI ' ] = '/pages/about ' ;
99+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
99100
100101 // Inject mock router.
101102 $ routes = Services::routes ();
@@ -193,6 +194,7 @@ public function testControllersCanReturnString()
193194 $ _SERVER ['argc ' ] = 2 ;
194195
195196 $ _SERVER ['REQUEST_URI ' ] = '/pages/about ' ;
197+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
196198
197199 // Inject mock router.
198200 $ routes = Services::routes ();
@@ -216,6 +218,7 @@ public function testControllersCanReturnResponseObject()
216218 $ _SERVER ['argc ' ] = 2 ;
217219
218220 $ _SERVER ['REQUEST_URI ' ] = '/pages/about ' ;
221+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
219222
220223 // Inject mock router.
221224 $ routes = Services::routes ();
@@ -244,6 +247,7 @@ public function testControllersCanReturnDownloadResponseObject()
244247 $ _SERVER ['argc ' ] = 2 ;
245248
246249 $ _SERVER ['REQUEST_URI ' ] = '/pages/about ' ;
250+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
247251
248252 // Inject mock router.
249253 $ routes = Services::routes ();
@@ -268,6 +272,7 @@ public function testRunExecuteFilterByClassName()
268272 $ _SERVER ['argc ' ] = 2 ;
269273
270274 $ _SERVER ['REQUEST_URI ' ] = '/pages/about ' ;
275+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
271276
272277 // Inject mock router.
273278 $ routes = Services::routes ();
@@ -298,6 +303,7 @@ public function testRegisterSameFilterTwiceWithDifferentArgument()
298303 $ _SERVER ['argc ' ] = 2 ;
299304
300305 $ _SERVER ['REQUEST_URI ' ] = '/pages/about ' ;
306+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
301307
302308 $ routes = Services::routes ();
303309 $ routes ->add (
@@ -331,6 +337,7 @@ public function testDisableControllerFilters()
331337 $ _SERVER ['argc ' ] = 2 ;
332338
333339 $ _SERVER ['REQUEST_URI ' ] = '/pages/about ' ;
340+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
334341
335342 // Inject mock router.
336343 $ routes = Services::routes ();
@@ -452,6 +459,7 @@ public function testRunRedirectionWithNamed()
452459 $ _SERVER ['argc ' ] = 2 ;
453460
454461 $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
462+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
455463
456464 // Inject mock router.
457465 $ routes = Services::routes ();
@@ -475,6 +483,7 @@ public function testRunRedirectionWithURI()
475483 $ _SERVER ['argc ' ] = 2 ;
476484
477485 $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
486+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
478487
479488 // Inject mock router.
480489 $ routes = Services::routes ();
@@ -501,6 +510,7 @@ public function testRunRedirectionWithGET()
501510 $ _SERVER ['argc ' ] = 2 ;
502511
503512 $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
513+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
504514 $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
505515 $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
506516
@@ -527,6 +537,7 @@ public function testRunRedirectionWithGETAndHTTPCode301()
527537 $ _SERVER ['argc ' ] = 2 ;
528538
529539 $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
540+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
530541 $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
531542 $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
532543
@@ -551,6 +562,7 @@ public function testRunRedirectionWithPOSTAndHTTPCode301()
551562 $ _SERVER ['argc ' ] = 2 ;
552563
553564 $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
565+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
554566 $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
555567 $ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
556568
@@ -615,6 +627,7 @@ public function testNotStoresPreviousURL()
615627 $ _SERVER ['argc ' ] = 2 ;
616628
617629 $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
630+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
618631 $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
619632 $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
620633
@@ -638,6 +651,7 @@ public function testNotStoresPreviousURLByCheckingContentType()
638651 $ _SERVER ['argc ' ] = 2 ;
639652
640653 $ _SERVER ['REQUEST_URI ' ] = '/image ' ;
654+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
641655
642656 // Inject mock router.
643657 $ routes = Services::routes ();
@@ -679,6 +693,7 @@ public function testRunCLIRoute()
679693 $ _SERVER ['argc ' ] = 2 ;
680694
681695 $ _SERVER ['REQUEST_URI ' ] = '/cli ' ;
696+ $ _SERVER ['SCRIPT_NAME ' ] = 'public/index.php ' ;
682697 $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
683698 $ _SERVER ['REQUEST_METHOD ' ] = 'CLI ' ;
684699
@@ -698,6 +713,7 @@ public function testSpoofRequestMethodCanUsePUT()
698713 $ _SERVER ['argc ' ] = 1 ;
699714
700715 $ _SERVER ['REQUEST_URI ' ] = '/ ' ;
716+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
701717 $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
702718 $ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
703719
@@ -722,6 +738,7 @@ public function testSpoofRequestMethodCannotUseGET()
722738 $ _SERVER ['argc ' ] = 1 ;
723739
724740 $ _SERVER ['REQUEST_URI ' ] = '/ ' ;
741+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
725742 $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
726743 $ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
727744
@@ -754,6 +771,7 @@ public function testPageCacheSendSecureHeaders()
754771 command ('cache:clear ' );
755772
756773 $ _SERVER ['REQUEST_URI ' ] = '/test ' ;
774+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
757775
758776 $ routes = Services::routes ();
759777 $ routes ->add ('test ' , static function () {
@@ -832,6 +850,7 @@ public function testPageCacheWithCacheQueryString(
832850 foreach ($ testingUrls as $ testingUrl ) {
833851 $ this ->resetServices ();
834852 $ _SERVER ['REQUEST_URI ' ] = '/ ' . $ testingUrl ;
853+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
835854 $ this ->codeigniter = new MockCodeIgniter (new App ());
836855
837856 $ routes = Services::routes (true );
0 commit comments