Skip to content

Commit 51840d2

Browse files
committed
Merge pull request #13 from barryp/issue_11
Render guid with isPermaLink=false
2 parents 96ff595 + 7ff29a5 commit 51840d2

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

src/Suin/RSSWriter/Item.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public function asXML()
108108
if ($this->guid) {
109109
$guid = $xml->addChild('guid', $this->guid);
110110

111-
if ($this->isPermalink) {
112-
$guid->addAttribute('isPermaLink', 'true');
111+
if ($this->isPermalink === false) {
112+
$guid->addAttribute('isPermaLink', 'false');
113113
}
114114
}
115115

tests/Suin/RSSWriter/ItemTest.php

+46-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,52 @@ public function testAsXML()
143143
<description>{$data['description']}</description>
144144
<category>{$data['categories'][0][0]}</category>
145145
<category domain=\"{$data['categories'][1][1]}\">{$data['categories'][1][0]}</category>
146-
<guid isPermaLink=\"true\">{$data['guid']}</guid>
146+
<guid>{$data['guid']}</guid>
147+
<pubDate>{$nowString}</pubDate>
148+
<enclosure url=\"{$data['enclosure']['url']}\" type=\"{$data['enclosure']['type']}\" length=\"{$data['enclosure']['length']}\"/>
149+
<author>{$data['author']}</author>
150+
</item>
151+
";
152+
$this->assertXmlStringEqualsXmlString($expect, $item->asXML()->asXML());
153+
}
154+
155+
public function testAsXML_false_permalink()
156+
{
157+
$now = time();
158+
$nowString = date(DATE_RSS, $now);
159+
160+
$data = array(
161+
'title' => "Venice Film Festival Tries to Quit Sinking",
162+
'url' => 'http://nytimes.com/2004/12/07FEST.html',
163+
'description' => "Some of the most heated chatter at the Venice Film Festival this week was about the way that the arrival of the stars at the Palazzo del Cinema was being staged.",
164+
'categories' => array(
165+
array("Grateful Dead", null),
166+
array("MSFT", 'http://www.fool.com/cusips'),
167+
),
168+
'guid' => "http://inessential.com/2002/09/01.php#a2",
169+
'isPermalink' => false,
170+
'pubDate' => $now,
171+
'enclosure' => array(
172+
'url' => 'http://link-to-audio-file.com/test.mp3',
173+
'length' => 4992,
174+
'type' => 'audio/mpeg'),
175+
'author' => 'Hidehito Nozawa aka Suin'
176+
);
177+
178+
$item = new Item();
179+
180+
foreach ($data as $key => $value) {
181+
$this->reveal($item)->attr($key, $value);
182+
}
183+
184+
$expect = "
185+
<item>
186+
<title>{$data['title']}</title>
187+
<link>{$data['url']}</link>
188+
<description>{$data['description']}</description>
189+
<category>{$data['categories'][0][0]}</category>
190+
<category domain=\"{$data['categories'][1][1]}\">{$data['categories'][1][0]}</category>
191+
<guid isPermaLink=\"false\">{$data['guid']}</guid>
147192
<pubDate>{$nowString}</pubDate>
148193
<enclosure url=\"{$data['enclosure']['url']}\" type=\"{$data['enclosure']['type']}\" length=\"{$data['enclosure']['length']}\"/>
149194
<author>{$data['author']}</author>

0 commit comments

Comments
 (0)