. * */ namespace Friendica\Test\src\Util; use Friendica\Test\MockedTest; use Friendica\Test\Util\HTTPInputDataDouble; use Friendica\Util\HTTPInputData; /** * Testing HTTPInputData * @see HTTPInputData */ class HTTPInputDataTest extends MockedTest { /** * Returns the data stream for the unit test * Each array element of the first hierarchy represents one test run * Each array element of the second hierarchy represents the parameters, passed to the test function * @return array[] */ public function dataStream() { return [ 'example' => [ 'input' => 'anything you want', 'expected' => [ 'variables' => [ 'var1' => 'value', 'var2' => 'value', ], 'files' => [] ] ] ]; } /** * Tests the HTTPInputData::process() method * @see HTTPInputData::process() * @param string $input The input, we got from the data stream * @param array $expected The expected output * @dataProvider dataStream */ public function testHttpInput(string $input, array $expected) { HTTPInputDataDouble::setPhpInputContent($input); $stream = fopen('php://memory', 'r+'); fwrite($stream, $input); rewind($stream); HTTPInputDataDouble::setPhpInputStream($stream); $output = HTTPInputDataDouble::process(); $this->assertEqualsCanonicalizing($output, $expected); } }