mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Tests for icon querying
This commit is contained in:
parent
76f1cc8e91
commit
cd5f13f4b9
2 changed files with 24 additions and 1 deletions
|
@ -820,7 +820,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
|||
return new Response([
|
||||
'id' => $icon['id'],
|
||||
'data' => ($icon['type'] ?: "application/octet-stream").";base64,".base64_encode($icon['data']),
|
||||
'mime_type' => $icon['type'],
|
||||
'mime_type' => ($icon['type'] ?: "application/octet-stream"),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -725,4 +725,27 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
$this->assertMessage(new ErrorResponse("404", 404), $this->req("DELETE", "/feeds/2112"));
|
||||
\Phake::verify(Arsse::$db)->subscriptionRemove(Arsse::$user->id, 2112);
|
||||
}
|
||||
|
||||
/** @dataProvider provideIcons */
|
||||
public function testGetTheIconOfASubscription($out, ResponseInterface $exp): void {
|
||||
if ($out instanceof \Exception) {
|
||||
\Phake::when(Arsse::$db)->subscriptionIcon->thenThrow($out);
|
||||
} else {
|
||||
\Phake::when(Arsse::$db)->subscriptionIcon->thenReturn($this->v($out));
|
||||
}
|
||||
$this->assertMessage($exp, $this->req("GET", "/feeds/2112/icon"));
|
||||
\Phake::verify(Arsse::$db)->subscriptionIcon(Arsse::$user->id, 2112);
|
||||
}
|
||||
|
||||
public function provideIcons(): iterable {
|
||||
self::clearData();
|
||||
return [
|
||||
[['id' => 44, 'type' => "image/svg+xml", 'data' => "<svg/>"], new Response(['id' => 44, 'data' => "image/svg+xml;base64,PHN2Zy8+", 'mime_type' => "image/svg+xml"])],
|
||||
[['id' => 47, 'type' => "", 'data' => "<svg/>"], new Response(['id' => 47, 'data' => "application/octet-stream;base64,PHN2Zy8+", 'mime_type' => "application/octet-stream"])],
|
||||
[['id' => 47, 'type' => null, 'data' => "<svg/>"], new Response(['id' => 47, 'data' => "application/octet-stream;base64,PHN2Zy8+", 'mime_type' => "application/octet-stream"])],
|
||||
[['id' => 47, 'type' => null, 'data' => null], new ErrorResponse("404", 404)],
|
||||
[null, new ErrorResponse("404", 404)],
|
||||
[new ExceptionInput("subjectMissing"), new ErrorResponse("404", 404)],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue