]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/HTTPInputData.php
Adapt tests using a content file
[friendica.git] / src / Util / HTTPInputData.php
index 526458acf6c4993e0e02ad5898a4fb4f6c72b2e4..322a462f12a0a79771ab2f9eb74208d0f1538b37 100644 (file)
@@ -58,7 +58,7 @@ class HTTPInputData
                }
 
                // can be handled by built in PHP functionality
-               $content = file_get_contents('php://input');
+               $content = static::getPhpInputContent();
 
                $variables = json_decode($content);
 
@@ -73,7 +73,7 @@ class HTTPInputData
        {
                $result = ['variables' => [], 'files' => []];
 
-               $stream = fopen('php://input', 'rb');
+               $stream = static::getPhpInputStream();
 
                $sanity = fgets($stream, strlen($boundary) + 5);
 
@@ -259,5 +259,24 @@ class HTTPInputData
 
                return $variables;
        }
+
+       /**
+        * Returns the current PHP input stream
+        * Mainly used for test doubling
+        * @return false|resource
+        */
+       protected static function getPhpInputStream()
+       {
+               return fopen('php://input', 'rb');
+       }
+
+       /**
+        * Returns the content of the current PHP input
+        * Mainly used for test doubling
+        * @return false|string
+        */
+       protected static function getPhpInputContent()
+       {
+               return file_get_contents('php://input');
+       }
 }
-?>