diff options
author | Paul Tirk <paultirk@paultirk.com> | 2021-03-28 21:41:50 +0200 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 10:23:11 +0200 |
commit | 1208dc8d7190ee3cb7b268083916538059da1c5f (patch) | |
tree | 8a4632810dd8b541a84f6bacf1d89c9d901db3f1 /tests/Unit/Db/ItemTest.php | |
parent | 8b3c1341e8d7da94e95c47f3695dc36b693fb333 (diff) |
add tests for 'toAPI2' method
Signed-off-by: Paul Tirk <paultirk@paultirk.com>
Diffstat (limited to 'tests/Unit/Db/ItemTest.php')
-rw-r--r-- | tests/Unit/Db/ItemTest.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/Unit/Db/ItemTest.php b/tests/Unit/Db/ItemTest.php index e5a2c844d..4f9de59d3 100644 --- a/tests/Unit/Db/ItemTest.php +++ b/tests/Unit/Db/ItemTest.php @@ -115,6 +115,69 @@ class ItemTest extends TestCase } + public function testToAPI2() + { + $item = new Item(); + $item->setId(3); + $item->setUrl('https://google'); + $item->setTitle('title'); + $item->setAuthor('author'); + $item->setPubDate(123); + $item->setBody('body'); + $item->setEnclosureMime('audio/ogg'); + $item->setEnclosureLink('enclink'); + $item->setMediaThumbnail('https://i2.ytimg.com/vi/E6B3uvhrcQk/hqdefault.jpg'); + $item->setMediaDescription('The best video ever'); + $item->setRtl(true); + $item->setFeedId(1); + $item->setUnread(true); + $item->setStarred(true); + $item->setLastModified('1111111111234567'); + $item->setFingerprint('fingerprint'); + $item->setContentHash('contentHash'); + + $this->assertEquals( + [ + 'id' => 3, + 'url' => 'https://google', + 'title' => 'title', + 'author' => 'author', + 'publishedAt' => date('c', 123), + 'lastModifiedAt' => date('c', 1111111111), + 'enclosure' => [ + 'mimeType' => 'audio/ogg', + 'url' => 'enclink', + ], + 'body' => 'body', + 'feedId' => 1, + 'isUnread' => true, + 'isStarred' => true, + 'fingerprint' => 'fingerprint', + 'contentHash' => 'contentHash' + ], + $item->toAPI2() + ); + } + + + public function testToAPI2Reduced() + { + $item = new Item(); + $item->setId(3); + $item->setUnread(true); + $item->setStarred(true); + + $this->assertEquals( + [ + 'id' => 3, + 'isUnread' => true, + 'isStarred' => true + ], + $item->toAPI2(true) + ); + } + + public function testJSONSerialize() { $item = new Item(); |