mirror of
https://github.com/Chouchen/ShikiryuRSS.git
synced 2025-10-27 01:23:07 +01:00
✅ Add new exceptions
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shikiryu\SRSS\Exception\SRSSException;
|
||||
use Shikiryu\SRSS\Exception\UnreadableRSSException;
|
||||
use Shikiryu\SRSS\SRSS;
|
||||
|
||||
class BasicReaderTest extends TestCase
|
||||
@@ -17,12 +18,6 @@ class BasicReaderTest extends TestCase
|
||||
self::assertTrue($rss->isValid());
|
||||
}
|
||||
|
||||
public function testRssNotFound()
|
||||
{
|
||||
$this->expectException(SRSSException::class);
|
||||
$rss = SRSS::read('not_found.xml');
|
||||
}
|
||||
|
||||
public function testSpecificationExampleRSS()
|
||||
{
|
||||
$rss = SRSS::read(__DIR__.'/resources/harvard.xml');
|
||||
|
||||
29
tests/ExceptionTest.php
Normal file
29
tests/ExceptionTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shikiryu\SRSS\Exception\ChannelNotFoundInRSSException;
|
||||
use Shikiryu\SRSS\Exception\PropertyNotFoundException;
|
||||
use Shikiryu\SRSS\Exception\UnreadableRSSException;
|
||||
use Shikiryu\SRSS\SRSS;
|
||||
|
||||
class ExceptionTest extends TestCase
|
||||
{
|
||||
public function testPropertyNotFound()
|
||||
{
|
||||
$srss = new SRSS();
|
||||
$this->expectException(PropertyNotFoundException::class);
|
||||
$srss->notfound = 'true';
|
||||
}
|
||||
|
||||
public function testRssNotFound()
|
||||
{
|
||||
$this->expectException(UnreadableRSSException::class);
|
||||
$rss = SRSS::read('not_found.xml');
|
||||
}
|
||||
|
||||
public function testMissingChannel()
|
||||
{
|
||||
$this->expectException(ChannelNotFoundInRSSException::class);
|
||||
$rss = SRSS::read(__DIR__ . '/resources/invalid-no-channel.xml');
|
||||
}
|
||||
}
|
||||
18
tests/resources/invalid-no-channel.xml
Normal file
18
tests/resources/invalid-no-channel.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
|
||||
<title>test Home Page</title>
|
||||
<link>https://www.test.com</link>
|
||||
<description>Free web building tutorials</description>
|
||||
<item>
|
||||
<title>RSS Tutorial</title>
|
||||
<link>https://www.test.com/xml/xml_rss.asp</link>
|
||||
<description>New RSS tutorial on test</description>
|
||||
</item>
|
||||
<item>
|
||||
<title>XML Tutorial</title>
|
||||
<link>https://www.test.com/xml</link>
|
||||
<description>New XML tutorial on test</description>
|
||||
</item>
|
||||
|
||||
</rss>
|
||||
Reference in New Issue
Block a user