Skip to content

Commit

Permalink
Added tests to use Xml with RSS.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Sep 1, 2010
1 parent 52b0918 commit edcb5e4
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions cake/tests/cases/libs/xml.test.php
Expand Up @@ -406,6 +406,61 @@ function testToArray() {
$this->assertEqual(Xml::toArray($obj), $expected);
}

/**
* testToArrayRss
*
* @return void
*/
function testToArrayRss() {
$rss = <<<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="http://bakery.cakephp.org/articles/rss" rel="self" type="application/rss+xml" />
<title>The Bakery: </title>
<link>http://bakery.cakephp.org/</link>
<description>Recent Articles at The Bakery.</description>
<language>en-us</language>
<pubDate>Wed, 01 Sep 2010 12:09:25 -0500</pubDate>
<docs>http://validator.w3.org/feed/docs/rss2.html</docs>
<generator>CakePHP Bakery</generator>
<managingEditor>mariano@cricava.com (Mariano Iglesias)</managingEditor>
<webMaster>gwoo@cakephp.org (Garrett Woodworth)</webMaster>
<item>
<title>EpisodeCMS</title>
<link>http://bakery.cakephp.org/articles/view/episodecms</link>
<description>EpisodeCMS is CakePHP based content management system.
Features: control panel, events API, module management, multilanguage and translations, themes
http://episodecms.com/
Please help me to improve it. Thanks.</description>
<pubDate>Tue, 31 Aug 2010 02:07:02 -0500</pubDate>
<guid>http://bakery.cakephp.org/articles/view/episodecms</guid>
</item>
<item>
<title>Alertpay automated sales via IPN</title>
<link>http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn</link>
<description>I&#039;m going to show you how I implemented a payment module via the Alertpay payment processor.</description>
<pubDate>Tue, 31 Aug 2010 01:42:00 -0500</pubDate>
<guid>http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn</guid>
</item>
</channel>
</rss>
EOF;
$rssAsArray = Xml::toArray(Xml::build($rss));
$this->assertEqual($rssAsArray['rss']['@version'], '2.0');
$this->assertEqual(count($rssAsArray['rss']['channel']['item']), 2);

$expected = array(
'title' => 'Alertpay automated sales via IPN',
'link' => 'http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn',
'description' => 'I\'m going to show you how I implemented a payment module via the Alertpay payment processor.',
'pubDate' => 'Tue, 31 Aug 2010 01:42:00 -0500',
'guid' => 'http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn'
);
$this->assertIdentical($rssAsArray['rss']['channel']['item'][1], $expected);
}

/**
* data provider for toArray() failures
*
Expand Down

0 comments on commit edcb5e4

Please sign in to comment.