Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/3126' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Dec 11, 2012
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Writer/Extension/Atom/Renderer/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
return;
}
foreach ($flinks as $type => $href) {
$mime = 'application/' . strtolower($type) . '+xml';
$flink = $dom->createElement('atom:link');
$root->appendChild($flink);
$flink->setAttribute('rel', 'self');
$flink->setAttribute('type', $mime);
$flink->setAttribute('href', $href);
if (strtolower($type) == $this->getType()) { // issue 2605
$mime = 'application/' . strtolower($type) . '+xml';
$flink = $dom->createElement('atom:link');
$root->appendChild($flink);
$flink->setAttribute('rel', 'self');
$flink->setAttribute('type', $mime);
$flink->setAttribute('href', $href);
}
}
$this->called = true;
}
Expand Down
15 changes: 15 additions & 0 deletions test/Writer/Renderer/Feed/RssTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,21 @@ public function testFeedLinkToHtmlVersionOfFeedIfMissingThrowsException()
$rssFeed->render();
}

/**
* @group Issue2605
*/
public function testFeedIncludesLinkToXmlRssWhereRssAndAtomLinksAreProvided()
{
$this->validWriter->setFeedLink('http://www.example.com/rss', 'rss');
$this->validWriter->setFeedLink('http://www.example.com/atom', 'atom');
$rssFeed = new Renderer\Feed\Rss($this->validWriter);
$rssFeed->render();
$feed = Reader\Reader::importString($rssFeed->saveXml());
$this->assertEquals('http://www.example.com/rss', $feed->getFeedLink());
$xpath = new \DOMXPath($feed->getDomDocument());
$this->assertEquals(1, $xpath->evaluate('/rss/channel/atom:link[@rel="self"]')->length);
}

public function testFeedIncludesLinkToXmlRssWhereTheFeedWillBeAvailable()
{
$this->validWriter->setFeedLink('http://www.example.com/rss', 'rss');
Expand Down

0 comments on commit b4cdf4e

Please sign in to comment.