Browse Source

RSS2 category test

master
J. King 4 years ago
parent
commit
763a039734
  1. 6
      lib/Parser/XML/Construct.php
  2. 14
      tests/cases/XML/feed-rss2.yaml

6
lib/Parser/XML/Construct.php

@ -346,7 +346,7 @@ abstract class Construct {
protected function getCategoriesRss2(): ?CategoryCollection {
$out = new CategoryCollection;
foreach ($this->xpath->query("rss2:category") as $node) {
foreach ($this->xpath->query("rss2:category", $this->subject) as $node) {
$c = new Category;
$c->domain = $this->trimText($node->getAttribute("domain"));
$c->name = $this->trimText($node->textContent);
@ -372,7 +372,7 @@ abstract class Construct {
protected function getCategoriesTunes(): ?CategoryCollection {
$out = new CategoryCollection;
foreach ($this->xpath->query("apple:category") ?? [] as $node) {
foreach ($this->xpath->query("apple:category", $this->subject) ?? [] as $node) {
$c = new Category;
$c->name = $this->trimText($node->getAttribute("text"));
if (strlen($c->name)) {
@ -384,7 +384,7 @@ abstract class Construct {
protected function getCategoriesGPlay(): ?CategoryCollection {
$out = new CategoryCollection;
foreach ($this->xpath->query("gplay:category") ?? [] as $node) {
foreach ($this->xpath->query("gplay:category", $this->subject) ?? [] as $node) {
$c = new Category;
$c->name = $this->trimText($node->getAttribute("text"));
if (strlen($c->name)) {

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

@ -381,3 +381,17 @@ Channel image:
output:
format: rss
image: 'http://example.com/'
Category:
input: >
<rss><channel>
<category>Category the first </category>
<category domain="ook eek">Category the second </category>
<category/>
</channel></rss>
output:
format: rss
categories:
- name: 'Category the first'
- name: 'Category the second'
domain: 'ook eek'

Loading…
Cancel
Save