Skip to content

Commit

Permalink
Merge pull request #3 from KillermenBE/master
Browse files Browse the repository at this point in the history
Changed guid
  • Loading branch information
dereuromark committed Feb 25, 2016
2 parents b603eda + 1b870dd commit 292554d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/View/RssView.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ protected function _prepareOutput($item) {
}
$val = $attrib;
} elseif (is_array($val) && isset($val['url'])) {
$val['url'] = Router::url($val['url'], true);
if (!isset($val['@isPermalink']) || $val['@isPermalink'] !== 'false') {
$val['url'] = Router::url($val['url'], true);
}
if ($bareKey === 'guid') {
$val['@'] = $val['url'];
unset($val['url']);
Expand Down
48 changes: 48 additions & 0 deletions tests/TestCase/View/RssViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,54 @@ public function testMedia() {
</channel>
</rss>
RSS;
$this->assertTextEquals($expected, $result);
}

public function testIsPermalink() {
$Request = new Request();
$Response = new Response();

$data = [
'channel' => [
'title' => 'Channel title',
],
'items' => [
[
'guid' => ['url' => 'Testing', '@isPermalink' => 'false'],
],
[
'guid' => ['url' => 'Testing', '@isPermalink' => 'true'],
],
[
'guid' => ['url' => 'Testing'],
],
]
];

$viewVars = ['channel' => $data, '_serialize' => 'channel'];
$View = new RssView($Request, $Response, null, ['viewVars' => $viewVars]);
$result = $View->render(false);

$expected = <<<RSS
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Channel title</title>
<link>/</link>
<description/>
<item>
<guid isPermalink="false">Testing</guid>
</item>
<item>
<guid isPermalink="true">/Testing</guid>
</item>
<item>
<guid>/Testing</guid>
</item>
</channel>
</rss>
RSS;
$this->assertTextEquals($expected, $result);
}
Expand Down

0 comments on commit 292554d

Please sign in to comment.