@@ -583,18 +583,28 @@ class Tester
583
583
array $ headers = [],
584
584
string $ uri = null ,
585
585
string $ scriptFilename = null ,
586
+ string $ scriptName = null ,
586
587
?string $ stdin = null
587
588
): 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 );
590
600
}
591
601
592
602
$ params = array_merge (
593
603
[
594
604
'GATEWAY_INTERFACE ' => 'FastCGI/1.0 ' ,
595
605
'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 ,
598
608
'QUERY_STRING ' => $ query ,
599
609
'REQUEST_URI ' => $ uri . ($ query ? '? ' . $ query : "" ),
600
610
'DOCUMENT_URI ' => $ uri ,
@@ -691,6 +701,7 @@ class Tester
691
701
* @param string|null $errorMessage
692
702
* @param bool $connKeepAlive
693
703
* @param string|null $scriptFilename = null
704
+ * @param string|null $scriptName = null
694
705
* @param string|array|null $stdin = null
695
706
* @param bool $expectError
696
707
* @param int $readLimit
@@ -707,6 +718,7 @@ class Tester
707
718
string $ errorMessage = null ,
708
719
bool $ connKeepAlive = false ,
709
720
string $ scriptFilename = null ,
721
+ string $ scriptName = null ,
710
722
string |array $ stdin = null ,
711
723
bool $ expectError = false ,
712
724
int $ readLimit = -1 ,
@@ -719,7 +731,7 @@ class Tester
719
731
$ stdin = $ this ->parseStdin ($ stdin , $ headers );
720
732
}
721
733
722
- $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename , $ stdin );
734
+ $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename , $ scriptName , $ stdin );
723
735
$ this ->trace ('Request params ' , $ params );
724
736
725
737
try {
@@ -1290,6 +1302,18 @@ class Tester
1290
1302
return $ this ->makeFile ('src.php ' , $ this ->code , overwrite: false );
1291
1303
}
1292
1304
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
+
1293
1317
/**
1294
1318
* @param string|null $msg
1295
1319
*/
0 commit comments