From 49c2431f1f0e18cab9a3d23eabbf5dd504c4798a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 May 2021 04:33:42 +0000 Subject: [PATCH] Two (hopefully) easy tests added --- .../http/form-urlencoded-json.httpinput | 1 + tests/datasets/http/form-urlencoded.httpinput | 1 + ...example1.httpinput => multipart.httpinput} | 0 tests/src/Util/HTTPInputDataTest.php | 28 +++++++++++++++++-- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/datasets/http/form-urlencoded-json.httpinput create mode 100644 tests/datasets/http/form-urlencoded.httpinput rename tests/datasets/http/{example1.httpinput => multipart.httpinput} (100%) 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/example1.httpinput b/tests/datasets/http/multipart.httpinput similarity index 100% rename from tests/datasets/http/example1.httpinput rename to tests/datasets/http/multipart.httpinput 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' => [] + ] ] ]; }