1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Finish last Guzzle-related tests

This commit is contained in:
J. King 2022-09-13 19:52:29 -04:00
parent 136d3782e3
commit 866800dcc5
3 changed files with 14 additions and 4 deletions

View file

@ -34,7 +34,7 @@ return [
'API.Miniflux.Error.InvalidTitle' => 'Invalid feed title', 'API.Miniflux.Error.InvalidTitle' => 'Invalid feed title',
'API.Miniflux.Error.InvalidImportCategory' => 'Payload contains an invalid category name', 'API.Miniflux.Error.InvalidImportCategory' => 'Payload contains an invalid category name',
'API.Miniflux.Error.DuplicateImportCategory' => 'Payload contains the same category name twice', '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.Miniflux.Error.InvalidImportLabel' => 'Payload contains an invalid label name',
'API.TTRSS.Category.Uncategorized' => 'Uncategorized', 'API.TTRSS.Category.Uncategorized' => 'Uncategorized',

View file

@ -46,6 +46,10 @@ class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest {
["respEmpty", [422, ['Content-Length' => "0"]], new Response(422, ['Content-Length' => "0"])], ["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"], 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")], ["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", ["<html/>"], new Response(200, ['Content-Type' => "application/xml; charset=UTF-8"], "<html/>")],
["respXml", ["<html/>", 451, ['Content-Type' => "text/plain", 'Vary' => "ETag"]], new Response(451, ['Content-Type' => "text/plain", 'Vary' => "ETag"], "<html/>")],
]; ];
} }
} }

View file

@ -98,6 +98,12 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
return $value; 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 */ /** @dataProvider provideAuthResponses */
public function testAuthenticateAUser($token, bool $auth, bool $success): void { public function testAuthenticateAUser($token, bool $auth, bool $success): void {
$exp = $success ? HTTP::respEmpty(404) : V1::respError("401", 401); $exp = $success ? HTTP::respEmpty(404) : V1::respError("401", 401);