From edcb5e4370443ef42fbe351334f65a82422942f7 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 1 Sep 2010 20:06:56 -0300 Subject: [PATCH] Added tests to use Xml with RSS. --- cake/tests/cases/libs/xml.test.php | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php index a423012b204..a04a38b3c0d 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -406,6 +406,61 @@ function testToArray() { $this->assertEqual(Xml::toArray($obj), $expected); } +/** + * testToArrayRss + * + * @return void + */ + function testToArrayRss() { + $rss = << + + + + The Bakery: + http://bakery.cakephp.org/ + Recent Articles at The Bakery. + en-us + Wed, 01 Sep 2010 12:09:25 -0500 + http://validator.w3.org/feed/docs/rss2.html + CakePHP Bakery + mariano@cricava.com (Mariano Iglesias) + gwoo@cakephp.org (Garrett Woodworth) + + EpisodeCMS + http://bakery.cakephp.org/articles/view/episodecms + 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. + Tue, 31 Aug 2010 02:07:02 -0500 + http://bakery.cakephp.org/articles/view/episodecms + + + Alertpay automated sales via IPN + http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn + I'm going to show you how I implemented a payment module via the Alertpay payment processor. + Tue, 31 Aug 2010 01:42:00 -0500 + http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn + + + +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 *