Browse Source

Test for icon fetching

rpm
J. King 4 years ago
parent
commit
50fd127ac4
  1. 2
      lib/Feed.php
  2. 8
      tests/cases/Feed/TestFeed.php
  3. 8
      tests/docroot/Feed/Parsing/WithIcon.php
  4. 4
      tests/docroot/Icon.php

2
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();

8
tests/cases/Feed/TestFeed.php

@ -347,4 +347,12 @@ class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest {
$exp = "<p>Partial content, followed by more content</p>";
$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);
}
}

8
tests/docroot/Feed/Parsing/WithIcon.php

@ -0,0 +1,8 @@
<?php return [
'mime' => "application/atom+xml",
'content' => <<<MESSAGE_BODY
<feed xmlns="http://www.w3.org/2005/Atom">
<icon>/Icon</icon>
</feed>
MESSAGE_BODY
];

4
tests/docroot/Icon.php

@ -0,0 +1,4 @@
<?php return [
'mime' => "image/png",
'content' => base64_decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAADUlEQVQYV2NgYGBgAAAABQABijPjAAAAAABJRU5ErkJggg=="),
];
Loading…
Cancel
Save