From: Michael Date: Mon, 24 May 2021 04:33:42 +0000 (+0000) Subject: Two (hopefully) easy tests added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=49c2431f1f0e18cab9a3d23eabbf5dd504c4798a;p=friendica.git Two (hopefully) easy tests added --- diff --git a/tests/datasets/http/example1.httpinput b/tests/datasets/http/example1.httpinput deleted file mode 100644 index b1498e476f..0000000000 --- a/tests/datasets/http/example1.httpinput +++ /dev/null @@ -1,50 +0,0 @@ ---43395968-f65c-437e-b536-5b33e3e3c7e5 -Content-Disposition: form-data; name="display_name" -Content-Transfer-Encoding: binary -Content-Type: multipart/form-data; charset=utf-8 -Content-Length: 9 - -User Name ---43395968-f65c-437e-b536-5b33e3e3c7e5 -Content-Disposition: form-data; name="note" -Content-Transfer-Encoding: binary -Content-Type: multipart/form-data; charset=utf-8 -Content-Length: 8 - -About me ---43395968-f65c-437e-b536-5b33e3e3c7e5 -Content-Disposition: form-data; name="locked" -Content-Transfer-Encoding: binary -Content-Type: multipart/form-data; charset=utf-8 -Content-Length: 5 - -false ---43395968-f65c-437e-b536-5b33e3e3c7e5 -Content-Disposition: form-data; name="fields_attributes[0][name]" -Content-Transfer-Encoding: binary -Content-Type: multipart/form-data; charset=utf-8 -Content-Length: 10 - -variable 1 ---43395968-f65c-437e-b536-5b33e3e3c7e5 -Content-Disposition: form-data; name="fields_attributes[0][value]" -Content-Transfer-Encoding: binary -Content-Type: multipart/form-data; charset=utf-8 -Content-Length: 7 - -value 1 ---43395968-f65c-437e-b536-5b33e3e3c7e5 -Content-Disposition: form-data; name="fields_attributes[1][name]" -Content-Transfer-Encoding: binary -Content-Type: multipart/form-data; charset=utf-8 -Content-Length: 10 - -variable 2 ---43395968-f65c-437e-b536-5b33e3e3c7e5 -Content-Disposition: form-data; name="fields_attributes[1][value]" -Content-Transfer-Encoding: binary -Content-Type: multipart/form-data; charset=utf-8 -Content-Length: 7 - -value 2 ---43395968-f65c-437e-b536-5b33e3e3c7e5-- diff --git a/tests/datasets/http/form-urlencoded-json.httpinput b/tests/datasets/http/form-urlencoded-json.httpinput new file mode 100644 index 0000000000..1970e30800 --- /dev/null +++ b/tests/datasets/http/form-urlencoded-json.httpinput @@ -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 index 0000000000..3a71aff994 --- /dev/null +++ b/tests/datasets/http/form-urlencoded.httpinput @@ -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 index 0000000000..b1498e476f --- /dev/null +++ b/tests/datasets/http/multipart.httpinput @@ -0,0 +1,50 @@ +--43395968-f65c-437e-b536-5b33e3e3c7e5 +Content-Disposition: form-data; name="display_name" +Content-Transfer-Encoding: binary +Content-Type: multipart/form-data; charset=utf-8 +Content-Length: 9 + +User Name +--43395968-f65c-437e-b536-5b33e3e3c7e5 +Content-Disposition: form-data; name="note" +Content-Transfer-Encoding: binary +Content-Type: multipart/form-data; charset=utf-8 +Content-Length: 8 + +About me +--43395968-f65c-437e-b536-5b33e3e3c7e5 +Content-Disposition: form-data; name="locked" +Content-Transfer-Encoding: binary +Content-Type: multipart/form-data; charset=utf-8 +Content-Length: 5 + +false +--43395968-f65c-437e-b536-5b33e3e3c7e5 +Content-Disposition: form-data; name="fields_attributes[0][name]" +Content-Transfer-Encoding: binary +Content-Type: multipart/form-data; charset=utf-8 +Content-Length: 10 + +variable 1 +--43395968-f65c-437e-b536-5b33e3e3c7e5 +Content-Disposition: form-data; name="fields_attributes[0][value]" +Content-Transfer-Encoding: binary +Content-Type: multipart/form-data; charset=utf-8 +Content-Length: 7 + +value 1 +--43395968-f65c-437e-b536-5b33e3e3c7e5 +Content-Disposition: form-data; name="fields_attributes[1][name]" +Content-Transfer-Encoding: binary +Content-Type: multipart/form-data; charset=utf-8 +Content-Length: 10 + +variable 2 +--43395968-f65c-437e-b536-5b33e3e3c7e5 +Content-Disposition: form-data; name="fields_attributes[1][value]" +Content-Transfer-Encoding: binary +Content-Type: multipart/form-data; charset=utf-8 +Content-Length: 7 + +value 2 +--43395968-f65c-437e-b536-5b33e3e3c7e5-- diff --git a/tests/src/Util/HTTPInputDataTest.php b/tests/src/Util/HTTPInputDataTest.php index a4e3ce20df..19e87e438a 100644 --- a/tests/src/Util/HTTPInputDataTest.php +++ b/tests/src/Util/HTTPInputDataTest.php @@ -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' => [] + ] ] ]; }