]> git.mxchange.org Git - friendica.git/commitdiff
Two (hopefully) easy tests added
authorMichael <heluecht@pirati.ca>
Mon, 24 May 2021 04:33:42 +0000 (04:33 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 24 May 2021 04:33:42 +0000 (04:33 +0000)
tests/datasets/http/example1.httpinput [deleted file]
tests/datasets/http/form-urlencoded-json.httpinput [new file with mode: 0644]
tests/datasets/http/form-urlencoded.httpinput [new file with mode: 0644]
tests/datasets/http/multipart.httpinput [new file with mode: 0644]
tests/src/Util/HTTPInputDataTest.php

diff --git a/tests/datasets/http/example1.httpinput b/tests/datasets/http/example1.httpinput
deleted file mode 100644 (file)
index b1498e4..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
---43395968-f65c-437e-b536-5b33e3e3c7e5\r
-Content-Disposition: form-data; name="display_name"\r
-Content-Transfer-Encoding: binary\r
-Content-Type: multipart/form-data; charset=utf-8\r
-Content-Length: 9\r
-\r
-User Name\r
---43395968-f65c-437e-b536-5b33e3e3c7e5\r
-Content-Disposition: form-data; name="note"\r
-Content-Transfer-Encoding: binary\r
-Content-Type: multipart/form-data; charset=utf-8\r
-Content-Length: 8\r
-\r
-About me\r
---43395968-f65c-437e-b536-5b33e3e3c7e5\r
-Content-Disposition: form-data; name="locked"\r
-Content-Transfer-Encoding: binary\r
-Content-Type: multipart/form-data; charset=utf-8\r
-Content-Length: 5\r
-\r
-false\r
---43395968-f65c-437e-b536-5b33e3e3c7e5\r
-Content-Disposition: form-data; name="fields_attributes[0][name]"\r
-Content-Transfer-Encoding: binary\r
-Content-Type: multipart/form-data; charset=utf-8\r
-Content-Length: 10\r
-\r
-variable 1\r
---43395968-f65c-437e-b536-5b33e3e3c7e5\r
-Content-Disposition: form-data; name="fields_attributes[0][value]"\r
-Content-Transfer-Encoding: binary\r
-Content-Type: multipart/form-data; charset=utf-8\r
-Content-Length: 7\r
-\r
-value 1\r
---43395968-f65c-437e-b536-5b33e3e3c7e5\r
-Content-Disposition: form-data; name="fields_attributes[1][name]"\r
-Content-Transfer-Encoding: binary\r
-Content-Type: multipart/form-data; charset=utf-8\r
-Content-Length: 10\r
-\r
-variable 2\r
---43395968-f65c-437e-b536-5b33e3e3c7e5\r
-Content-Disposition: form-data; name="fields_attributes[1][value]"\r
-Content-Transfer-Encoding: binary\r
-Content-Type: multipart/form-data; charset=utf-8\r
-Content-Length: 7\r
-\r
-value 2\r
---43395968-f65c-437e-b536-5b33e3e3c7e5--\r
diff --git a/tests/datasets/http/form-urlencoded-json.httpinput b/tests/datasets/http/form-urlencoded-json.httpinput
new file mode 100644 (file)
index 0000000..1970e30
--- /dev/null
@@ -0,0 +1 @@
+{"media_ids":[],"sensitive":false,"status":"Test Status","visibility":"private","spoiler_text":"Title"}
\ No newline at end of file
diff --git a/tests/datasets/http/form-urlencoded.httpinput b/tests/datasets/http/form-urlencoded.httpinput
new file mode 100644 (file)
index 0000000..3a71aff
--- /dev/null
@@ -0,0 +1 @@
+title=Test2
\ No newline at end of file
diff --git a/tests/datasets/http/multipart.httpinput b/tests/datasets/http/multipart.httpinput
new file mode 100644 (file)
index 0000000..b1498e4
--- /dev/null
@@ -0,0 +1,50 @@
+--43395968-f65c-437e-b536-5b33e3e3c7e5\r
+Content-Disposition: form-data; name="display_name"\r
+Content-Transfer-Encoding: binary\r
+Content-Type: multipart/form-data; charset=utf-8\r
+Content-Length: 9\r
+\r
+User Name\r
+--43395968-f65c-437e-b536-5b33e3e3c7e5\r
+Content-Disposition: form-data; name="note"\r
+Content-Transfer-Encoding: binary\r
+Content-Type: multipart/form-data; charset=utf-8\r
+Content-Length: 8\r
+\r
+About me\r
+--43395968-f65c-437e-b536-5b33e3e3c7e5\r
+Content-Disposition: form-data; name="locked"\r
+Content-Transfer-Encoding: binary\r
+Content-Type: multipart/form-data; charset=utf-8\r
+Content-Length: 5\r
+\r
+false\r
+--43395968-f65c-437e-b536-5b33e3e3c7e5\r
+Content-Disposition: form-data; name="fields_attributes[0][name]"\r
+Content-Transfer-Encoding: binary\r
+Content-Type: multipart/form-data; charset=utf-8\r
+Content-Length: 10\r
+\r
+variable 1\r
+--43395968-f65c-437e-b536-5b33e3e3c7e5\r
+Content-Disposition: form-data; name="fields_attributes[0][value]"\r
+Content-Transfer-Encoding: binary\r
+Content-Type: multipart/form-data; charset=utf-8\r
+Content-Length: 7\r
+\r
+value 1\r
+--43395968-f65c-437e-b536-5b33e3e3c7e5\r
+Content-Disposition: form-data; name="fields_attributes[1][name]"\r
+Content-Transfer-Encoding: binary\r
+Content-Type: multipart/form-data; charset=utf-8\r
+Content-Length: 10\r
+\r
+variable 2\r
+--43395968-f65c-437e-b536-5b33e3e3c7e5\r
+Content-Disposition: form-data; name="fields_attributes[1][value]"\r
+Content-Transfer-Encoding: binary\r
+Content-Type: multipart/form-data; charset=utf-8\r
+Content-Length: 7\r
+\r
+value 2\r
+--43395968-f65c-437e-b536-5b33e3e3c7e5--\r
index a4e3ce20df8f3adae4d51d69c0aaae0a6ccf1cbb..19e87e438a5802e5f335f0699cf50374ad169489 100644 (file)
@@ -40,9 +40,9 @@ class HTTPInputDataTest extends MockedTest
        public function dataStream()
        {
                return [
-                       'example' => [
+                       'multipart' => [
                                'contenttype' => 'multipart/form-data;boundary=43395968-f65c-437e-b536-5b33e3e3c7e5;charset=utf8',
-                               'input'       => file_get_contents(__DIR__ . '/../../datasets/http/example1.httpinput'),
+                               'input'       => file_get_contents(__DIR__ . '/../../datasets/http/multipart.httpinput'),
                                'expected'    => [
                                        'variables' => [
                                                'display_name'      => 'User Name',
@@ -61,6 +61,30 @@ class HTTPInputDataTest extends MockedTest
                                        ],
                                        'files' => []
                                ]
+                       ],
+                       'form-urlencoded' => [
+                               'contenttype' => 'application/x-www-form-urlencoded;charset=utf8',
+                               'input'       => file_get_contents(__DIR__ . '/../../datasets/http/form-urlencoded.httpinput'),
+                               'expected'    => [
+                                       'variables' => [
+                                               'title' => 'Test2',
+                                       ],
+                                       'files' => []
+                               ]
+                       ],
+                       'form-urlencoded-json' => [
+                               'contenttype' => 'application/x-www-form-urlencoded;charset=utf8',
+                               'input'       => file_get_contents(__DIR__ . '/../../datasets/http/form-urlencoded-json.httpinput'),
+                               'expected'    => [
+                                       'variables' => [
+                                               'media_ids'    => [],
+                                               'sensitive'    => false, 
+                                               'status'       => 'Test Status',
+                                               'visibility'   => 'private',
+                                               'spoiler_text' => 'Title'
+                                       ],
+                                       'files' => []
+                               ]
                        ]
                ];
        }