]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/HTTPInputDataTest.php
Changed variable type
[friendica.git] / tests / src / Util / HTTPInputDataTest.php
index f1deaa7ffa5c2365a06605a4c2da0f6461c7aa66..a4e3ce20df8f3adae4d51d69c0aaae0a6ccf1cbb 100644 (file)
@@ -41,11 +41,23 @@ class HTTPInputDataTest extends MockedTest
        {
                return [
                        'example' => [
-                               'input'    => 'anything you want',
-                               'expected' => [
+                               'contenttype' => 'multipart/form-data;boundary=43395968-f65c-437e-b536-5b33e3e3c7e5;charset=utf8',
+                               'input'       => file_get_contents(__DIR__ . '/../../datasets/http/example1.httpinput'),
+                               'expected'    => [
                                        'variables' => [
-                                               'var1' => 'value',
-                                               'var2' => 'value',
+                                               'display_name'      => 'User Name',
+                                               'note'              => 'About me',
+                                               'locked'            => 'false',
+                                               'fields_attributes' => [
+                                                       0 => [
+                                                               'name'  => 'variable 1',
+                                                               'value' => 'value 1',
+                                                       ],
+                                                       1 => [
+                                                               'name'  => 'variable 2',
+                                                               'value' => 'value 2',
+                                                       ]
+                                               ]
                                        ],
                                        'files' => []
                                ]
@@ -56,12 +68,15 @@ class HTTPInputDataTest extends MockedTest
        /**
         * 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
+        * @param string $contenttype The content typer of the transmitted data
+        * @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)
+       public function testHttpInput(string $contenttype, string $input, array $expected)
        {
+               $_SERVER['CONTENT_TYPE'] = $contenttype;
+
                HTTPInputDataDouble::setPhpInputContent($input);
                $stream = fopen('php://memory', 'r+');
                fwrite($stream, $input);
@@ -69,6 +84,6 @@ class HTTPInputDataTest extends MockedTest
 
                HTTPInputDataDouble::setPhpInputStream($stream);
                $output = HTTPInputDataDouble::process();
-               $this->assertEqualsCanonicalizing($output, $expected);
+               $this->assertEqualsCanonicalizing($expected, $output);
        }
 }