/** * @covers Debril\RssAtomBundle\Protocol\Parser\RssParser::parseBody */ public function testParseWithDublinCoreExtension() { $file = dirname(__FILE__) . '/../../../Resources/sample-rss-creator.xml'; $xmlBody = new \SimpleXMLElement(file_get_contents($file)); $date = \DateTime::createFromFormat('Y-m-d', '2005-10-10'); $filters = array(new ModifiedSince($date)); $feed = $this->object->parse($xmlBody, new FeedContent(), $filters); $this->assertGreaterThan(0, $feed->getItemsCount()); $item = current($feed->getItems()); $this->assertInternalType('string', $item->getAuthor()); $this->assertEquals('John Doe', $item->getAuthor()); }
/** * @covers Debril\RssAtomBundle\Protocol\Parser\RssParser::parseBody */ public function testParseWithoutDate() { $file = dirname(__FILE__) . '/../../../Resources/sample-rss-nodate.xml'; $xmlBody = new \SimpleXMLElement(file_get_contents($file)); $date = \DateTime::createFromFormat('Y-m-d', '2005-10-10'); $filters = array(new ModifiedSince($date)); $feed = $this->object->parse($xmlBody, new FeedContent(), $filters); $this->assertInstanceOf('Debril\\RssAtomBundle\\Protocol\\FeedInInterface', $feed); $this->assertNotNull($feed->getPublicId(), 'feed->getPublicId() should not return an empty value'); $this->assertGreaterThan(0, $feed->getItemsCount()); $this->assertInstanceOf('\\DateTime', $feed->getLastModified()); $feeds = $feed->getItems(); $item = next($feeds); $this->assertEquals($item->getUpdated(), $feed->getLastModified()); }