2023-04-05 14:44:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2023-04-07 17:57:35 +02:00
|
|
|
use Shikiryu\SRSS\Exception\SRSSException;
|
2023-04-12 00:27:35 +02:00
|
|
|
use Shikiryu\SRSS\Exception\UnreadableRSSException;
|
2023-04-05 14:44:57 +02:00
|
|
|
use Shikiryu\SRSS\SRSS;
|
|
|
|
|
2023-04-07 17:57:35 +02:00
|
|
|
class BasicReaderTest extends TestCase
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
|
|
|
public function testReadBasicRSS()
|
|
|
|
{
|
|
|
|
$rss = SRSS::read(__DIR__.'/resources/basic.xml');
|
|
|
|
self::assertEquals('test Home Page', $rss->title);
|
|
|
|
$first_item = $rss->getFirst();
|
2023-04-06 00:38:26 +02:00
|
|
|
self::assertNotNull($first_item);
|
2023-04-05 14:44:57 +02:00
|
|
|
self::assertEquals('RSS Tutorial', $first_item->title);
|
2023-04-07 00:35:20 +02:00
|
|
|
|
2023-04-07 17:57:35 +02:00
|
|
|
self::assertTrue($rss->isValid());
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
|
2023-04-06 11:07:06 +02:00
|
|
|
public function testSpecificationExampleRSS()
|
|
|
|
{
|
|
|
|
$rss = SRSS::read(__DIR__.'/resources/harvard.xml');
|
|
|
|
self::assertEquals('Liftoff News', $rss->title);
|
|
|
|
self::assertEquals('http://liftoff.msfc.nasa.gov/', $rss->link);
|
|
|
|
self::assertEquals('Liftoff to Space Exploration.', $rss->description);
|
|
|
|
self::assertEquals('en-us', $rss->language);
|
|
|
|
self::assertEquals('Tue, 10 Jun 2003 04:00:00 GMT', $rss->pubDate);
|
|
|
|
self::assertEquals('Tue, 10 Jun 2003 09:41:01 GMT', $rss->lastBuildDate);
|
|
|
|
self::assertEquals('http://blogs.law.harvard.edu/tech/rss', $rss->docs);
|
|
|
|
self::assertEquals('Weblog Editor 2.0', $rss->generator);
|
|
|
|
self::assertEquals('editor@example.com', $rss->managingEditor);
|
|
|
|
self::assertEquals('webmaster@example.com', $rss->webMaster);
|
|
|
|
self::assertCount(4, $rss->items);
|
|
|
|
self::assertEquals('Star City', $rss->getFirst()->title);
|
|
|
|
self::assertEquals('http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp', $rss->getLast()->link);
|
|
|
|
self::assertEquals('Fri, 30 May 2003 11:06:42 GMT', $rss->getItem(2)->pubDate);
|
2023-04-07 00:35:20 +02:00
|
|
|
|
2023-04-07 17:57:35 +02:00
|
|
|
self::assertTrue($rss->isValid());
|
2023-04-06 11:07:06 +02:00
|
|
|
}
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|