@@ -534,7 +534,8 @@ class Tester
534534 string $ query = '' ,
535535 array $ headers = [],
536536 string $ uri = null ,
537- string $ scriptFilename = null
537+ string $ scriptFilename = null ,
538+ ?string $ stdin = null
538539 ) {
539540 if (is_null ($ uri )) {
540541 $ uri = $ this ->makeSourceFile ();
@@ -543,7 +544,7 @@ class Tester
543544 $ params = array_merge (
544545 [
545546 'GATEWAY_INTERFACE ' => 'FastCGI/1.0 ' ,
546- 'REQUEST_METHOD ' => 'GET ' ,
547+ 'REQUEST_METHOD ' => is_null ( $ stdin ) ? 'GET ' : ' POST ' ,
547548 'SCRIPT_FILENAME ' => $ scriptFilename ?: $ uri ,
548549 'SCRIPT_NAME ' => $ uri ,
549550 'QUERY_STRING ' => $ query ,
@@ -558,7 +559,7 @@ class Tester
558559 'SERVER_PROTOCOL ' => 'HTTP/1.1 ' ,
559560 'DOCUMENT_ROOT ' => __DIR__ ,
560561 'CONTENT_TYPE ' => '' ,
561- 'CONTENT_LENGTH ' => 0
562+ 'CONTENT_LENGTH ' => strlen ( $ stdin ?? "" ) // Default to 0
562563 ],
563564 $ headers
564565 );
@@ -589,17 +590,18 @@ class Tester
589590 string $ successMessage = null ,
590591 string $ errorMessage = null ,
591592 bool $ connKeepAlive = false ,
592- string $ scriptFilename = null
593+ string $ scriptFilename = null ,
594+ string $ stdin = null
593595 ) {
594596 if ($ this ->hasError ()) {
595597 return new Response (null , true );
596598 }
597599
598- $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename );
600+ $ params = $ this ->getRequestParams ($ query , $ headers , $ uri , $ scriptFilename, $ stdin );
599601
600602 try {
601603 $ this ->response = new Response (
602- $ this ->getClient ($ address , $ connKeepAlive )->request_data ($ params , false )
604+ $ this ->getClient ($ address , $ connKeepAlive )->request_data ($ params , $ stdin )
603605 );
604606 $ this ->message ($ successMessage );
605607 } catch (\Exception $ exception ) {
0 commit comments