This commit is contained in:
2022-11-25 21:21:30 +01:00
parent 2d6df0d5f0
commit 94deb06f52
132 changed files with 44887 additions and 41368 deletions

View File

@@ -1,4 +1,5 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
@@ -12,31 +13,31 @@ use Domframework\Rss;
/** 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_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, "<?xml version=\"1.0\"?>
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, "<?xml version=\"1.0\"?>
<rss version=\"2.0\">
<channel>
<title>Global Title</title>
@@ -57,99 +58,109 @@ class RssTest extends \PHPUnit_Framework_TestCase
</channel>
</rss>
");
}
}
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_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_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_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_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_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_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 ();
}
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();
}
}