@@ -583,18 +583,28 @@ class Tester
583583 array $ headers = [],
584584 string $ uri = null ,
585585 string $ scriptFilename = null ,
586+ string $ scriptName = null ,
586587 ?string $ stdin = null
587588 ): array {
588- if (is_null ($ uri )) {
589- $ uri = $ this ->makeSourceFile ();
589+ if (is_null ($ scriptFilename ) && is_null ($ uri )) {
590+ $ scriptFilename = $ this ->makeSourceFile ();
591+ } else {
592+ if (is_null ($ scriptFilename )) {
593+ $ scriptFilename = $ uri ;
594+ } elseif (is_null ($ scriptName )) {
595+ $ scriptName = $ uri ;
596+ }
597+ }
598+ if (is_null ($ scriptName )) {
599+ $ scriptName = '/ ' . basename ($ scriptFilename );
590600 }
591601
592602 $ params = array_merge (
593603 [
594604 'GATEWAY_INTERFACE ' => 'FastCGI/1.0 ' ,
595605 'REQUEST_METHOD ' => is_null ($ stdin ) ? 'GET ' : 'POST ' ,
596- 'SCRIPT_FILENAME ' => $ scriptFilename ? : $ uri ,
597- 'SCRIPT_NAME ' => $ uri ,
606+ 'SCRIPT_FILENAME ' => $ scriptFilename === '' ? null : $ scriptFilename ,
607+ 'SCRIPT_NAME ' => $ scriptName ,
598608 'QUERY_STRING ' => $ query ,
599609 'REQUEST_URI ' => $ uri . ($ query ? '? ' . $ query : "" ),
600610 'DOCUMENT_URI ' => $ uri ,
@@ -691,6 +701,7 @@ class Tester
691701 * @param string|null $errorMessage
692702 * @param bool $connKeepAlive
693703 * @param string|null $scriptFilename = null
704+ * @param string|null $scriptName = null
694705 * @param string|array|null $stdin = null
695706 * @param bool $expectError
696707 * @param int $readLimit
@@ -707,6 +718,7 @@ class Tester
707718 string $ errorMessage = null ,
708719 bool $ connKeepAlive = false ,
709720 string $ scriptFilename = null ,
721+ string $ scriptName = null ,
710722 string |array $ stdin = null ,
711723 bool $ expectError = false ,
712724 int $ readLimit = -1 ,
@@ -719,7 +731,7 @@ class Tester
719731 $ stdin = $ this ->parseStdin ($ stdin , $ headers );
720732 }
721733
722- $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename , $ stdin );
734+ $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename , $ scriptName , $ stdin );
723735 $ this ->trace ('Request params ' , $ params );
724736
725737 try {
@@ -1290,6 +1302,18 @@ class Tester
12901302 return $ this ->makeFile ('src.php ' , $ this ->code , overwrite: false );
12911303 }
12921304
1305+ /**
1306+ * Create a source file and script name.
1307+ *
1308+ * @return string[]
1309+ */
1310+ public function createSourceFileAndScriptName (): array
1311+ {
1312+ $ sourceFile = $ this ->makeFile ('src.php ' , $ this ->code , overwrite: false );
1313+
1314+ return [$ sourceFile , '/ ' . basename ($ sourceFile )];
1315+ }
1316+
12931317 /**
12941318 * @param string|null $msg
12951319 */
0 commit comments