]> git.mxchange.org Git - friendica.git/blobdiff - tests/Util/HTTPInputDataDouble.php
Merge pull request #10311 from fabrixxm/fix/consoleautoinstall
[friendica.git] / tests / Util / HTTPInputDataDouble.php
index c00fa6fad9297e88b80399b2c68540db3d6716e7..391b9c82bb2d4f45842523d97c12fb21342e5489 100644 (file)
@@ -33,9 +33,12 @@ class HTTPInputDataDouble extends HTTPInputData
        protected static $injectedStream = false;
        /** @var false|string */
        protected static $injectedContent = false;
+       /** @var false|string */
+       protected static $injectedContentType = false;
 
        /**
         * injects the PHP input stream for a test
+        *
         * @param false|resource $stream
         */
        public static function setPhpInputStream($stream)
@@ -45,6 +48,7 @@ class HTTPInputDataDouble extends HTTPInputData
 
        /**
         * injects the PHP input content for a test
+        *
         * @param false|string $content
         */
        public static function setPhpInputContent($content)
@@ -52,6 +56,16 @@ class HTTPInputDataDouble extends HTTPInputData
                self::$injectedContent = $content;
        }
 
+       /**
+        * injects the PHP input content type for a test
+        *
+        * @param false|string $contentType
+        */
+       public static function setPhpInputContentType($contentType)
+       {
+               self::$injectedContentType = $contentType;
+       }
+
        /** {@inheritDoc} */
        protected static function getPhpInputStream()
        {
@@ -63,4 +77,21 @@ class HTTPInputDataDouble extends HTTPInputData
        {
                return static::$injectedContent;
        }
+
+       /** {@inheritDoc} */
+       protected static function getContentType()
+       {
+               return static::$injectedContentType;
+       }
+
+       protected static function fetchFileData($stream, string $boundary, array $headers, string $filename)
+       {
+               $data = parent::fetchFileData($stream, $boundary, $headers, $filename);
+               if (!empty($data['tmp_name'])) {
+                       unlink($data['tmp_name']);
+                       $data['tmp_name'] = $data['name'];
+               }
+
+               return $data;
+       }
 }