From 80465c6633e6827bb26c5113803f0d64e0b3ebaa Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 3 Jul 2023 12:42:27 +0900 Subject: [PATCH] test: set $_SERVER['SCRIPT_NAME'] --- tests/system/CodeIgniterTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index 25ee4eda832a..584310ba08c6 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -96,6 +96,7 @@ public function testRunClosureRoute() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/pages/about'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -193,6 +194,7 @@ public function testControllersCanReturnString() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/pages/about'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -216,6 +218,7 @@ public function testControllersCanReturnResponseObject() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/pages/about'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -244,6 +247,7 @@ public function testControllersCanReturnDownloadResponseObject() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/pages/about'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -268,6 +272,7 @@ public function testRunExecuteFilterByClassName() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/pages/about'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -298,6 +303,7 @@ public function testRegisterSameFilterTwiceWithDifferentArgument() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/pages/about'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $routes = Services::routes(); $routes->add( @@ -331,6 +337,7 @@ public function testDisableControllerFilters() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/pages/about'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -452,6 +459,7 @@ public function testRunRedirectionWithNamed() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/example'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -475,6 +483,7 @@ public function testRunRedirectionWithURI() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/example'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -501,6 +510,7 @@ public function testRunRedirectionWithGET() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/example'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -527,6 +537,7 @@ public function testRunRedirectionWithGETAndHTTPCode301() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/example'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -551,6 +562,7 @@ public function testRunRedirectionWithPOSTAndHTTPCode301() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/example'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -615,6 +627,7 @@ public function testNotStoresPreviousURL() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/example'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -638,6 +651,7 @@ public function testNotStoresPreviousURLByCheckingContentType() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/image'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; // Inject mock router. $routes = Services::routes(); @@ -679,6 +693,7 @@ public function testRunCLIRoute() $_SERVER['argc'] = 2; $_SERVER['REQUEST_URI'] = '/cli'; + $_SERVER['SCRIPT_NAME'] = 'public/index.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['REQUEST_METHOD'] = 'CLI'; @@ -698,6 +713,7 @@ public function testSpoofRequestMethodCanUsePUT() $_SERVER['argc'] = 1; $_SERVER['REQUEST_URI'] = '/'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -722,6 +738,7 @@ public function testSpoofRequestMethodCannotUseGET() $_SERVER['argc'] = 1; $_SERVER['REQUEST_URI'] = '/'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -754,6 +771,7 @@ public function testPageCacheSendSecureHeaders() command('cache:clear'); $_SERVER['REQUEST_URI'] = '/test'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $routes = Services::routes(); $routes->add('test', static function () { @@ -832,6 +850,7 @@ public function testPageCacheWithCacheQueryString( foreach ($testingUrls as $testingUrl) { $this->resetServices(); $_SERVER['REQUEST_URI'] = '/' . $testingUrl; + $_SERVER['SCRIPT_NAME'] = '/index.php'; $this->codeigniter = new MockCodeIgniter(new App()); $routes = Services::routes(true);