@@ -534,7 +534,8 @@ class Tester
534
534
string $ query = '' ,
535
535
array $ headers = [],
536
536
string $ uri = null ,
537
- string $ scriptFilename = null
537
+ string $ scriptFilename = null ,
538
+ ?string $ stdin = null
538
539
) {
539
540
if (is_null ($ uri )) {
540
541
$ uri = $ this ->makeSourceFile ();
@@ -543,7 +544,7 @@ class Tester
543
544
$ params = array_merge (
544
545
[
545
546
'GATEWAY_INTERFACE ' => 'FastCGI/1.0 ' ,
546
- 'REQUEST_METHOD ' => 'GET ' ,
547
+ 'REQUEST_METHOD ' => is_null ( $ stdin ) ? 'GET ' : ' POST ' ,
547
548
'SCRIPT_FILENAME ' => $ scriptFilename ?: $ uri ,
548
549
'SCRIPT_NAME ' => $ uri ,
549
550
'QUERY_STRING ' => $ query ,
@@ -558,7 +559,7 @@ class Tester
558
559
'SERVER_PROTOCOL ' => 'HTTP/1.1 ' ,
559
560
'DOCUMENT_ROOT ' => __DIR__ ,
560
561
'CONTENT_TYPE ' => '' ,
561
- 'CONTENT_LENGTH ' => 0
562
+ 'CONTENT_LENGTH ' => strlen ( $ stdin ?? "" ) // Default to 0
562
563
],
563
564
$ headers
564
565
);
@@ -589,17 +590,18 @@ class Tester
589
590
string $ successMessage = null ,
590
591
string $ errorMessage = null ,
591
592
bool $ connKeepAlive = false ,
592
- string $ scriptFilename = null
593
+ string $ scriptFilename = null ,
594
+ string $ stdin = null
593
595
) {
594
596
if ($ this ->hasError ()) {
595
597
return new Response (null , true );
596
598
}
597
599
598
- $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename );
600
+ $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename, $ stdin );
599
601
600
602
try {
601
603
$ this ->response = new Response (
602
- $ this ->getClient ($ address , $ connKeepAlive )->request_data ($ params , false )
604
+ $ this ->getClient ($ address , $ connKeepAlive )->request_data ($ params , $ stdin )
603
605
);
604
606
$ this ->message ($ successMessage );
605
607
} catch (\Exception $ exception ) {
0 commit comments