* @license BSD */ namespace Domframework\Tests; /** Test the RSS */ class rssTest extends \PHPUnit_Framework_TestCase { public function test_empty0 () { // Empty $this->expectException ("Exception", "No title is provided for this RSS"); $rss = new rss (); $res = $rss->asXML (); } public function test_functional1 () { // Functionnal 1 $rss = new rss (); $rss->title ("Global Title") ->link ("http://localhost") ->language ("fr-fr") ->description ("The Super Global Description"); $rss->addItem ()->title ("Item1 Title") ->link ("http://Item1Link") ->description ("Item1 Description"); $rss->addItem ()->title ("Item2 Title") ->pubDate ("2017-04-13 12:25:30") ->link ("http://Item2Link") ->description ("Item2 Description"); $res = $rss->asXML (); $this->assertSame ($res, " Global Title http://localhost The Super Global Description fr-fr Item1 Title http://Item1Link Item1 Description Item2 Title http://Item2Link Item2 Description Thu, 13 Apr 2017 12:25:30 +0200 "); } public function test_error1 () { // Missing global description $this->expectException ("Exception", "No description is provided for this RSS"); $rss = new rss (); $rss->title ("Global Title") ->link ("http://localhost") ->language ("fr-fr"); $res = $rss->asXML (); } public function test_error2 () { // Missing global link $this->expectException ("Exception", "No link is provided for this RSS"); $rss = new rss (); $rss->title ("Global Title") ->language ("fr-fr") ->description ("The Super Global Description"); $res = $rss->asXML (); } public function test_error3 () { // Missing global title $this->expectException ("Exception", "No title is provided for this RSS"); $rss = new rss (); $rss->link ("http://localhost") ->language ("fr-fr") ->description ("The Super Global Description"); $res = $rss->asXML (); } public function test_error4 () { // Invalid date provided $this->expectException ("Exception", "lastBuildDate provided to RSS is not a valid date"); $rss = new rss (); $rss->title ("Global Title") ->link ("http://localhost") ->lastBuildDate ("2017-04-33") ->language ("fr-fr") ->description ("The Super Global Description"); $res = $rss->asXML (); } public function test_itemError1 () { // Empty Item provided $this->expectException ("Exception", "No title nor description defined in the RSS item"); $rss = new rss (); $rss->title ("Global Title") ->link ("http://localhost") ->lastBuildDate ("2017-04-30 12:35:32") ->language ("fr-fr") ->description ("The Super Global Description"); $rss->addItem (); $res = $rss->asXML (); } public function test_itemError2 () { // Item without Title and Description $this->expectException ("Exception", "No title nor description defined in the RSS item"); $rss = new rss (); $rss->title ("Global Title") ->link ("http://localhost") ->lastBuildDate ("2017-04-30 12:35:32") ->language ("fr-fr") ->description ("The Super Global Description"); $rss->addItem ()->link ("http://localhost/link"); $res = $rss->asXML (); } public function test_itemError3 () { // Item with invalid date $this->expectException ("Exception", "pubDate provided to RSS Item is not a valid date"); $rss = new rss (); $rss->title ("Global Title") ->link ("http://localhost") ->lastBuildDate ("2017-10-30 12:35:32") ->language ("fr-fr") ->description ("The Super Global Description"); $rss->addItem ()->title ("Item title") ->pubDate ("2017-14-33 12:32:32"); $res = $rss->asXML (); } }