<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
'files' => []
]
],
+ 'multipart-file' => [
+ 'contenttype' => 'multipart/form-data;boundary=6d4d5a40-651a-4468-a62e-5a6ca2bf350d;charset=utf8',
+ 'input' => file_get_contents(__DIR__ . '/../../datasets/http/multipart-file.httpinput'),
+ 'expected' => [
+ 'variables' => [
+ 'display_name' => 'Vorname Nachname',
+ 'note' => 'About me',
+ 'fields_attributes' => [
+ 0 => [
+ 'name' => 'variable 1',
+ 'value' => 'value 1',
+ ],
+ 1 => [
+ 'name' => 'variable 2',
+ 'value' => 'value 2',
+ ]
+ ]
+ ],
+ 'files' => [
+ 'avatar' => [
+ 'name' => '8ZUCS34Y5XNH',
+ 'type' => 'image/png',
+ 'tmp_name' => '8ZUCS34Y5XNH',
+ 'error' => 0,
+ 'size' => 349330
+ ],
+ 'header' => [
+ 'name' => 'V2B6Z1IICGPM',
+ 'type' => 'image/png',
+ 'tmp_name' => 'V2B6Z1IICGPM',
+ 'error' => 0,
+ 'size' => 1323635
+ ]
+ ]
+ ]
+ ],
'form-urlencoded' => [
'contenttype' => 'application/x-www-form-urlencoded;charset=utf8',
'input' => file_get_contents(__DIR__ . '/../../datasets/http/form-urlencoded.httpinput'),
'input' => file_get_contents(__DIR__ . '/../../datasets/http/form-urlencoded-json.httpinput'),
'expected' => [
'variables' => [
- 'media_ids' => [1],
+ 'media_ids' => [],
'sensitive' => false,
'status' => 'Test Status',
'visibility' => 'private',
*/
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);
}
}