Browse Source

Feed image tests

master
J. King 4 years ago
parent
commit
303a39a3e5
  1. 12
      lib/Parser/XML/Feed.php
  2. 10
      tests/cases/XML/feed-atom.yaml
  3. 18
      tests/cases/XML/feed-other.yaml
  4. 56
      tests/cases/XML/feed-rss0.yaml
  5. 44
      tests/cases/XML/feed-rss1.yaml
  6. 11
      tests/cases/XML/feed-rss2.yaml

12
lib/Parser/XML/Feed.php

@ -90,7 +90,7 @@ class Feed extends Construct implements \MensBeam\Lax\Parser\Feed {
$feed->summary = $this->getSummary();
$feed->dateModified = $this->getDateModified();
$feed->icon = $this->getIcon();
//$feed->image = $this->getImage();
$feed->image = $this->getImage();
//$feed->people = $this->getPeople();
//$feed->categories = $this->getCategories();
//$feed->entries = $this->getEntries($feed);
@ -170,11 +170,11 @@ class Feed extends Construct implements \MensBeam\Lax\Parser\Feed {
}
public function getImage(): ?Url {
return $this->fetchUrl("atom:logo") // Atom logo URL
?? $this->fetchUrl("(rss0:image|rss1:image)/url") // RSS 0.90 or RSS 1.0 channel image
?? $this->fetchUrl("(/rss0:image|/rss1:image)/url") // RSS 0.90 or RSS 1.0 root image
?? $this->fetchUrl("image/url") // RSS 2.0 channel image
?? $this->fetchURL("(apple:image|gplay:image)/@href"); // iTunes or Google Play podcast image
return $this->fetchUrl("atom:logo") // Atom logo URL
?? $this->fetchUrl("rss0:image/rss0:url|rss1:image/rss1:url") // RSS 0.90 or RSS 1.0 channel image
?? $this->fetchUrl("/rdf:RDF/rss0:image/rss0:url|/rdf:RDF/rss1:image/rss1:url") // RSS 0.90 or RSS 1.0 root image
?? $this->fetchUrl("image/url") // RSS 2.0 channel image
?? $this->fetchUrl("(apple:image|gplay:image)/@href"); // iTunes or Google Play podcast image
}
public function getCategories(): CategoryCollection {

10
tests/cases/XML/feed-atom.yaml

@ -435,3 +435,13 @@ Reversed shortcut icon relation URL:
format: atom
version: '1.0'
icon: 'http://example.com/'
Logo URL:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<logo>http://example.com/</logo>
</feed>
output:
format: atom
version: '1.0'
image: 'http://example.com/'

18
tests/cases/XML/feed-other.yaml

@ -83,3 +83,21 @@ Google Play summary:
format: rss
summary:
plain: 'Plain text'
iTunes image:
input: >
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:play="http://www.google.com/schemas/play-podcasts/1.0"><channel>
<itunes:image href="http://example.com/"/>
</channel></rss>
output:
format: rss
image: 'http://example.com/'
Google Play image:
input: >
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:play="http://www.google.com/schemas/play-podcasts/1.0"><channel>
<play:image href="http://example.com/"/>
</channel></rss>
output:
format: rss
image: 'http://example.com/'

56
tests/cases/XML/feed-rss0.yaml

@ -59,9 +59,9 @@ Feed link:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<channel>
<link/>
<link>http://[example.net]/</link>
<link>http://example.com/</link>
<link/>
<link>http://[example.net]/</link>
<link>http://example.com/</link>
</channel>
</rdf:RDF>
output:
@ -73,7 +73,7 @@ Feed title 1:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<channel>
<title> Loose text</title>
<title> Loose text</title>
</channel>
</rdf:RDF>
output:
@ -86,7 +86,7 @@ Feed title 2:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<channel>
<title xml:base="https://example.com/"> Loose text</title>
<title xml:base="https://example.com/"> Loose text</title>
</channel>
</rdf:RDF>
output:
@ -100,7 +100,7 @@ Feed summary:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<channel>
<description>Loose text</description>
<description>Loose text</description>
</channel>
</rdf:RDF>
output:
@ -108,3 +108,47 @@ Feed summary:
version: '0.90'
summary:
loose: 'Loose text'
Feed channel image:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<channel>
<image>
<url>http://example.com/</url>
</image>
</channel>
</rdf:RDF>
output:
format: rdf
version: '0.90'
image: 'http://example.com/'
Feed root image:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<channel/>
<image>
<url>http://example.com/</url>
</image>
</rdf:RDF>
output:
format: rdf
version: '0.90'
image: 'http://example.com/'
Feed channel and root images:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<image>
<url>http://example.net/</url>
</image>
<channel>
<image>
<url>http://example.com/</url>
</image>
</channel>
</rdf:RDF>
output:
format: rdf
version: '0.90'
image: 'http://example.com/'

44
tests/cases/XML/feed-rss1.yaml

@ -295,3 +295,47 @@ Multiple DC dates:
format: rdf
version: '1.0'
dateModified: '2020-03-03T00:00:00-04:00'
Feed channel image:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel>
<image>
<url>http://example.com/</url>
</image>
</channel>
</rdf:RDF>
output:
format: rdf
version: '1.0'
image: 'http://example.com/'
Feed root image:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel/>
<image>
<url>http://example.com/</url>
</image>
</rdf:RDF>
output:
format: rdf
version: '1.0'
image: 'http://example.com/'
Feed channel and root images:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<image>
<url>http://example.net/</url>
</image>
<channel>
<image>
<url>http://example.com/</url>
</image>
</channel>
</rdf:RDF>
output:
format: rdf
version: '1.0'
image: 'http://example.com/'

11
tests/cases/XML/feed-rss2.yaml

@ -370,3 +370,14 @@ Multiple dates 2:
output:
format: rss
dateModified: '2020-03-03T00:00:00-04:00'
Channel image:
input: >
<rss><channel>
<image>
<url>http://example.com/</url>
</image>
</channel></rss>
output:
format: rss
image: 'http://example.com/'

Loading…
Cancel
Save