<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
class HTTPInputDataDouble extends HTTPInputData
{
/** @var false|resource */
- protected static $injectedStream = false;
+ protected $injectedStream = false;
/** @var false|string */
- protected static $injectedContent = false;
+ protected $injectedContent = false;
/**
* injects the PHP input stream for a test
+ *
* @param false|resource $stream
*/
- public static function setPhpInputStream($stream)
+ public function setPhpInputStream($stream)
{
- self::$injectedStream = $stream;
+ $this->injectedStream = $stream;
}
/**
* injects the PHP input content for a test
+ *
* @param false|string $content
*/
- public static function setPhpInputContent($content)
+ public function setPhpInputContent($content)
{
- self::$injectedContent = $content;
+ $this->injectedContent = $content;
+ }
+
+ /**
+ * injects the PHP input content type for a test
+ *
+ * @param false|string $contentType
+ */
+ public function setPhpInputContentType($contentType)
+ {
+ $this->injectedContentType = $contentType;
}
/** {@inheritDoc} */
- protected static function getPhpInputStream()
+ protected function getPhpInputStream()
{
- return static::$injectedStream;
+ return $this->injectedStream;
}
/** {@inheritDoc} */
- protected static function getPhpInputContent()
+ protected function getPhpInputContent()
{
- return static::$injectedContent;
+ return $this->injectedContent;
+ }
+
+ protected 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;
}
}