Merge remote-tracking branch 'upstream/2021.12-rc' into api-fixes

This commit is contained in:
Michael 2021-11-30 19:07:24 +00:00
commit 56f8adcb80
152 changed files with 339 additions and 335 deletions

View file

@ -30,20 +30,18 @@ use Friendica\Util\HTTPInputData;
class HTTPInputDataDouble extends HTTPInputData
{
/** @var false|resource */
protected static $injectedStream = false;
protected $injectedStream = false;
/** @var false|string */
protected static $injectedContent = false;
/** @var false|string */
protected static $injectedContentType = 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;
}
/**
@ -51,9 +49,9 @@ class HTTPInputDataDouble extends HTTPInputData
*
* @param false|string $content
*/
public static function setPhpInputContent($content)
public function setPhpInputContent($content)
{
self::$injectedContent = $content;
$this->injectedContent = $content;
}
/**
@ -61,30 +59,24 @@ class HTTPInputDataDouble extends HTTPInputData
*
* @param false|string $contentType
*/
public static function setPhpInputContentType($contentType)
public function setPhpInputContentType($contentType)
{
self::$injectedContentType = $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;
}
/** {@inheritDoc} */
protected static function getContentType()
{
return static::$injectedContentType;
}
protected static function fetchFileData($stream, string $boundary, array $headers, string $filename)
protected function fetchFileData($stream, string $boundary, array $headers, string $filename)
{
$data = parent::fetchFileData($stream, $boundary, $headers, $filename);
if (!empty($data['tmp_name'])) {

View file

@ -51,7 +51,7 @@ class DeleteTest extends ApiTest
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
$response = $delete->run([], ['photo_id' => '709057080661a283a6aa598501504178']);
$response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']);
$responseText = (string)$response->getBody();
@ -68,7 +68,7 @@ class DeleteTest extends ApiTest
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
$response = $delete->run([], ['photo_id' => '709057080661a283a6aa598501504178']);
$response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']);
$responseText = (string)$response->getBody();

View file

@ -47,7 +47,7 @@ class DeleteTest extends ApiTest
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
$response = $delete->run([], ['album' => 'test_album']);
$response = $delete->run(['album' => 'test_album']);
$responseText = (string)$response->getBody();

View file

@ -56,7 +56,7 @@ class UpdateTest extends ApiTest
{
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run([], ['album' => 'test_album', 'album_new' => 'test_album_2']);
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'test_album', 'album_new' => 'test_album_2']);
$responseBody = (string)$response->getBody();

View file

@ -139,14 +139,15 @@ class HTTPInputDataTest extends MockedTest
*/
public function testHttpInput(string $contentType, string $input, array $expected)
{
HTTPInputDataDouble::setPhpInputContentType($contentType);
HTTPInputDataDouble::setPhpInputContent($input);
$httpInput = new HTTPInputDataDouble(['CONTENT_TYPE' => $contentType]);
$httpInput->setPhpInputContent($input);
$stream = fopen('php://memory', 'r+');
fwrite($stream, $input);
rewind($stream);
HTTPInputDataDouble::setPhpInputStream($stream);
$output = HTTPInputDataDouble::process();
$httpInput->setPhpInputStream($stream);
$output = $httpInput->process();
$this->assertEqualsCanonicalizing($expected, $output);
}
}