From 866800dcc501cc52609c80d53062c474b867aa3b Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 13 Sep 2022 19:52:29 -0400 Subject: [PATCH] Finish last Guzzle-related tests --- locale/en.php | 2 +- tests/cases/Misc/TestHTTP.php | 10 +++++++--- tests/cases/REST/Miniflux/TestV1.php | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/locale/en.php b/locale/en.php index a439a45..c954647 100644 --- a/locale/en.php +++ b/locale/en.php @@ -34,7 +34,7 @@ return [ 'API.Miniflux.Error.InvalidTitle' => 'Invalid feed title', 'API.Miniflux.Error.InvalidImportCategory' => 'Payload contains an invalid category name', 'API.Miniflux.Error.DuplicateImportCategory' => 'Payload contains the same category name twice', - 'API.Miniflux.Error.FailedImportFeed' => 'Unable to import feed at URL "{url}" (code {code}', + 'API.Miniflux.Error.FailedImportFeed' => 'Unable to import feed at URL "{url}" (code {code})', 'API.Miniflux.Error.InvalidImportLabel' => 'Payload contains an invalid label name', 'API.TTRSS.Category.Uncategorized' => 'Uncategorized', diff --git a/tests/cases/Misc/TestHTTP.php b/tests/cases/Misc/TestHTTP.php index 71eec8c..fee9a67 100644 --- a/tests/cases/Misc/TestHTTP.php +++ b/tests/cases/Misc/TestHTTP.php @@ -43,9 +43,13 @@ class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest { public function provideTypedMessages(): iterable { return [ - ["respEmpty", [422, ['Content-Length' => "0"]], new Response(422, ['Content-Length' => "0"])], - ["respText", ["OOK"], new Response(200, ['Content-Type' => "text/plain; charset=UTF-8"], "OOK")], - ["respText", ["OOK", 201, ['Content-Type' => "application/octet-stream"]], new Response(201, ['Content-Type' => "application/octet-stream"], "OOK")], + ["respEmpty", [422, ['Content-Length' => "0"]], new Response(422, ['Content-Length' => "0"])], + ["respText", ["OOK"], new Response(200, ['Content-Type' => "text/plain; charset=UTF-8"], "OOK")], + ["respText", ["OOK", 201, ['Content-Type' => "application/octet-stream"]], new Response(201, ['Content-Type' => "application/octet-stream"], "OOK")], + ["respJson", [['ook' => "eek"]], new Response(200, ['Content-Type' => "application/json"], '{"ook":"eek"}')], + ["respJson", [['ook' => "eek"], 400, ['Content-Type' => "application/feed+json"]], new Response(400, ['Content-Type' => "application/feed+json"], '{"ook":"eek"}')], + ["respXml", [""], new Response(200, ['Content-Type' => "application/xml; charset=UTF-8"], "")], + ["respXml", ["", 451, ['Content-Type' => "text/plain", 'Vary' => "ETag"]], new Response(451, ['Content-Type' => "text/plain", 'Vary' => "ETag"], "")], ]; } } diff --git a/tests/cases/REST/Miniflux/TestV1.php b/tests/cases/REST/Miniflux/TestV1.php index ca4ae1f..9e3aa3c 100644 --- a/tests/cases/REST/Miniflux/TestV1.php +++ b/tests/cases/REST/Miniflux/TestV1.php @@ -98,6 +98,12 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest { return $value; } + public function testGenerateErrorResponse() { + $act = V1::respError(["DuplicateUser", 'user' => "john.doe"], 409, ['Cache-Control' => "no-store"]); + $exp = HTTP::respJson(['error_message' => 'The user name "john.doe" already exists'], 409, ['Cache-Control' => "no-store"]); + $this->assertMessage($exp, $act); + } + /** @dataProvider provideAuthResponses */ public function testAuthenticateAUser($token, bool $auth, bool $success): void { $exp = $success ? HTTP::respEmpty(404) : V1::respError("401", 401);