Browse Source

Title, content, and summary tests

master
J. King 4 years ago
parent
commit
f37de9a5c2
  1. 2
      lib/Parser/XML/Entry.php
  2. 36
      tests/cases/XML/entry-atom.yaml
  3. 50
      tests/cases/XML/entry-other.yaml
  4. 24
      tests/cases/XML/entry-rss0.yaml
  5. 69
      tests/cases/XML/entry-rss1.yaml
  6. 24
      tests/cases/XML/entry-rss2.yaml

2
lib/Parser/XML/Entry.php

@ -89,7 +89,7 @@ class Entry extends Construct implements \MensBeam\Lax\Parser\Entry {
formats are equal, and we want the latest date, whatever it is.
*/
return $this->fetchDate("atom:updated", self::DATE_LATEST) // Atom update date
?? $this->fetchDate(self::QUERY_AMBIGUOUS_DATES, self::DATE_LATEST); // Latest other datee
?? $this->fetchDate(self::QUERY_AMBIGUOUS_DATES, self::DATE_LATEST); // Latest other date
}
public function getDateCreated(): ?Date {

36
tests/cases/XML/entry-atom.yaml

@ -111,3 +111,39 @@ Creation and update dates:
entries:
- dateCreated: '2020-01-01T00:00:00Z'
dateModified: '2020-04-01T00:00:00Z'
Entry title:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry><title type="html" xml:base="http://example.com/">HTML title</title></entry>
<entry><title>Plain title</title></entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- title: {html: 'HTML title', htmlBase: 'http://example.com/'}
- title: 'Plain title'
Content and summary:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<content>Plain content</content>
<summary>Plain summary</summary>
</entry>
<entry>
<content>Plain content</content>
</entry>
<entry>
<summary>Plain summary</summary>
</entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- content: 'Plain content'
summary: 'Plain summary'
- content: 'Plain content'
- summary: 'Plain summary'

50
tests/cases/XML/entry-other.yaml

@ -0,0 +1,50 @@
# This file tests extensions primarily designed for RSS 2
iTunes title:
input: >
<rss><channel xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<item>
<itunes:title> Plain title</itunes:title>
</item>
</channel></rss>
output:
format: rss
entries:
- title: 'Plain title'
Explicitly encoded content:
input: >
<rss><channel xmlns:content="http://purl.org/rss/1.0/modules/content/">
<item>
<description>Loose content</description>
<content:encoded>HTML content</content:encoded>
</item>
</channel></rss>
output:
format: rss
entries:
- content: {html: 'HTML content'}
iTunes summary:
input: >
<rss><channel xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<item>
<itunes:summary> Plain summary</itunes:summary>
</item>
</channel></rss>
output:
format: rss
entries:
- summary: 'Plain summary'
Google Play summary:
input: >
<rss><channel xmlns:play="http://www.google.com/schemas/play-podcasts/1.0">
<item>
<play:description> Plain summary</play:description>
</item>
</channel></rss>
output:
format: rss
entries:
- summary: 'Plain summary'

24
tests/cases/XML/entry-rss0.yaml

@ -28,3 +28,27 @@ Entry link:
entries:
- link: 'http://example.com/'
- link: 'http://example.com/'
Entry title:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<item>
<title>Loose title</title>
</item>
</rdf:RDF>
output:
format: rdf
version: '0.90'
entries:
- title: {loose: 'Loose title'}
Entry content: # RSS 0.90 didn't have entry descriptions
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/">
<item>
<description>Bogus description</description>
</item>
</rdf:RDF>
output:
format: rdf
version: '0.90'

69
tests/cases/XML/entry-rss1.yaml

@ -165,3 +165,72 @@ Dublin Core terms dates:
- dateModified: '2020-03-03T00:00:00Z'
- dateModified: '2020-03-03T00:00:00Z'
- dateModified: '2020-03-03T00:00:00Z'
Entry and Dublin Core titles:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:term="http://purl.org/dc/terms/">
<item><title>Loose title</title></item>
<item><dc:title>Plain title</dc:title></item>
<item><term:title>Plain title</term:title></item>
<item>
<dc:title>Plain title</dc:title>
<title>Loose title</title>
</item>
</rdf:RDF>
output:
format: rdf
version: '1.0'
entries:
- title: {loose: 'Loose title'}
- title: {plain: 'Plain title'}
- title: {plain: 'Plain title'}
- title: {loose: 'Loose title'} # Native titles take precedence over DC titles
Entry content:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<item>
<description>Loose content</description>
</item>
</rdf:RDF>
output:
format: rdf
version: '1.0'
entries:
- content: {loose: 'Loose content'}
Explicitly encoded content:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<item>
<description>Loose content</description>
<content:encoded>HTML content</content:encoded>
</item>
</rdf:RDF>
output:
format: rdf
version: '1.0'
entries:
- content: {html: 'HTML content'}
Dublin Core summary:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:term="http://purl.org/dc/terms/">
<item><dc:description>Plain summary</dc:description></item>
<item><dc:abstract>Plain summary</dc:abstract></item>
<item><term:description>Plain summary</term:description></item>
<item><term:abstract>Plain summary</term:abstract></item>
<item>
<term:description>Description</term:description>
<term:abstract>Abstract</term:abstract>
</item>
</rdf:RDF>
output:
format: rdf
version: '1.0'
entries:
- summary: 'Plain summary'
- summary: 'Plain summary'
- summary: 'Plain summary'
- summary: 'Plain summary'
- summary: 'Abstract'

24
tests/cases/XML/entry-rss2.yaml

@ -116,3 +116,27 @@ Update and creation dates:
- dateCreated: '2020-01-01T00:00:00Z'
dateModified: '2020-03-03T00:00:00Z'
- dateModified: '2020-03-03T01:00:00+01:00'
Entry title:
input: >
<rss><channel>
<item>
<title> Loose title</title>
</item>
</channel></rss>
output:
format: rss
entries:
- title: {loose: 'Loose title'}
Entry content:
input: >
<rss><channel>
<item>
<description> Loose content</description>
</item>
</channel></rss>
output:
format: rss
entries:
- content: {loose: 'Loose content'}

Loading…
Cancel
Save