From 50fd127ac4cac17dcc1a0daa01c0439404799ff9 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Thu, 5 Nov 2020 10:14:42 -0500 Subject: [PATCH] Test for icon fetching --- lib/Feed.php | 2 +- tests/cases/Feed/TestFeed.php | 8 ++++++++ tests/docroot/Feed/Parsing/WithIcon.php | 8 ++++++++ tests/docroot/Icon.php | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/docroot/Feed/Parsing/WithIcon.php create mode 100644 tests/docroot/Icon.php diff --git a/lib/Feed.php b/lib/Feed.php index 2dad326..dffbccb 100644 --- a/lib/Feed.php +++ b/lib/Feed.php @@ -125,7 +125,7 @@ class Feed { // Some feeds might use a different domain (eg: feedburner), so the site url is // used instead of the feed's url. $icon = new Favicon; - $this->iconUrl = $icon->find($feed->siteUrl); + $this->iconUrl = $icon->find($feed->siteUrl, $feed->getIcon()); $this->iconData = $icon->getContent(); if (strlen($this->iconData)) { $this->iconType = $icon->getType(); diff --git a/tests/cases/Feed/TestFeed.php b/tests/cases/Feed/TestFeed.php index 01f4f5f..562d906 100644 --- a/tests/cases/Feed/TestFeed.php +++ b/tests/cases/Feed/TestFeed.php @@ -347,4 +347,12 @@ class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest { $exp = "

Partial content, followed by more content

"; $this->assertSame($exp, $f->newItems[0]->content); } + + public function testFetchWithIcon(): void { + $d = base64_decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAADUlEQVQYV2NgYGBgAAAABQABijPjAAAAAABJRU5ErkJggg=="); + $f = new Feed(null, $this->base."Parsing/WithIcon"); + $this->assertSame(self::$host."Icon", $f->iconUrl); + $this->assertSame("image/png", $f->iconType); + $this->assertSame($d, $f->iconData); + } } diff --git a/tests/docroot/Feed/Parsing/WithIcon.php b/tests/docroot/Feed/Parsing/WithIcon.php new file mode 100644 index 0000000..4f1f277 --- /dev/null +++ b/tests/docroot/Feed/Parsing/WithIcon.php @@ -0,0 +1,8 @@ + "application/atom+xml", + 'content' => << + /Icon + +MESSAGE_BODY +]; diff --git a/tests/docroot/Icon.php b/tests/docroot/Icon.php new file mode 100644 index 0000000..f5c54d6 --- /dev/null +++ b/tests/docroot/Icon.php @@ -0,0 +1,4 @@ + "image/png", + 'content' => base64_decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAADUlEQVQYV2NgYGBgAAAABQABijPjAAAAAABJRU5ErkJggg=="), +];