From 2623615d67df5ac91e4fee503200f94d40c3047c Mon Sep 17 00:00:00 2001 From: Damien Debin Date: Fri, 13 Sep 2019 14:27:55 +0200 Subject: [PATCH] Bugfix for custom elements. --- src/Feed.php | 12 ++++++------ tests/FeedTest.php | 2 +- tests/feed_1.xml | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Feed.php b/src/Feed.php index 6fa38e8..d156b0d 100644 --- a/src/Feed.php +++ b/src/Feed.php @@ -138,18 +138,18 @@ public function getEntries(): array /** * @param string $ns - * @param string $url + * @param string $uri * @param string $name * @param mixed $value * @param null|string[] $attributes */ - public function addCustomElement(string $ns, string $url, string $name, $value, ?array $attributes = null): void + public function addCustomElement(string $ns, string $uri, string $name, $value, ?array $attributes = null): void { - self::assertURL($url); + self::assertURL($uri); $this->customElements[] = [ 'ns' => $ns, - 'url' => $url, + 'uri' => $uri, 'name' => $name, 'value' => $value, 'attributes' => $attributes ?? [], @@ -186,7 +186,7 @@ public function addChildrenTo(SimpleXMLElement $parent): void } foreach ($this->customElements as $customElement) { - $element = $parent->addChild($customElement['name'], $customElement['value'], $customElement['ns']); + $element = $parent->addChild($customElement['name'], $customElement['value'], $customElement['uri']); foreach ($customElement['attributes'] as $name => $value) { $element->addAttribute($name, $value); } @@ -207,7 +207,7 @@ public function getSimpleXML(): SimpleXMLElement $attributes['xml:lang'] = $this->language; } foreach ($this->customElements as $customElement) { - $attributes['xmlns:'.$customElement['ns']] = $customElement['url']; + $attributes['xmlns:'.$customElement['ns']] = $customElement['uri']; } $attributesString = ''; diff --git a/tests/FeedTest.php b/tests/FeedTest.php index 423a32b..0c2e4d5 100644 --- a/tests/FeedTest.php +++ b/tests/FeedTest.php @@ -40,7 +40,7 @@ public function testFeedCreation1(): void $feed->addContributor('contributor', 'contributor@test.com', 'http://test.com/contributor'); $feed->setUpdatedDateTime(new DateTime('2019-05-04T20:00:40Z')); $feed->addCustomElement('sy', 'http://purl.org/rss/1.0/modules/syndication', 'updatePeriod', 'hourly'); - $feed->addCustomElement('sy', 'http://purl.org/rss/1.0/modules/syndication', 'sy:updateFrequency', 10); + $feed->addCustomElement('sy', 'http://purl.org/rss/1.0/modules/syndication', 'updateFrequency', 10); $entry = new Entry(); $entry->setTitle('entry title', 'text'); diff --git a/tests/feed_1.xml b/tests/feed_1.xml index 6f35558..b77fb6d 100644 --- a/tests/feed_1.xml +++ b/tests/feed_1.xml @@ -25,8 +25,8 @@ http://test.com/logo http://test.com/icon generator - hourly - 10 + hourly + 10 tag:entry-test entry title