From c044c36af653f3fa61259ed923a2d497c0cb53e1 Mon Sep 17 00:00:00 2001 From: Alex Debril Date: Sat, 3 Jun 2017 18:41:22 +0200 Subject: [PATCH] Fix #66 --- src/FeedIo/Standard/Rss.php | 2 ++ tests/FeedIo/ParserTest.php | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/FeedIo/Standard/Rss.php b/src/FeedIo/Standard/Rss.php index f09e7933..202291ca 100644 --- a/src/FeedIo/Standard/Rss.php +++ b/src/FeedIo/Standard/Rss.php @@ -42,6 +42,8 @@ class Rss extends StandardAbstract */ const DATE_NODE_TAGNAME = 'pubDate'; + protected $mandatoryFields = ['channel']; + /** * Formats the document according to the standard's specification * @param \DOMDocument $document diff --git a/tests/FeedIo/ParserTest.php b/tests/FeedIo/ParserTest.php index 96af9930..ee01a513 100644 --- a/tests/FeedIo/ParserTest.php +++ b/tests/FeedIo/ParserTest.php @@ -12,13 +12,14 @@ use FeedIo\Feed\Item; use FeedIo\Rule\DateTimeBuilder; +use FeedIo\Standard\Rss; use Psr\Log\NullLogger; class ParserTest extends \PHPUnit_Framework_TestCase { /** - * @var \FeedIo\ParserAbstract + * @var \FeedIo\Parser */ protected $object; @@ -150,6 +151,22 @@ public function testAddResetFilters() $this->assertAttributeCount(0, 'filters', $this->object); } + /** + * @expectedException \FeedIo\Parser\MissingFieldsException + */ + public function testParseEmptyRssFeed() + { + $rss = << +RSS; + $document = new \DOMDocument(); + $document->loadXML($rss); + $parser = new Parser(new Rss( + new DateTimeBuilder() + ), new NullLogger()); + $parser->parse($document, new Feed()); + } + /** * @param boolean $returnValue * @return \FeedIo\FilterInterface