/** * @covers Zend\Feed\Writer\Feed::addTombstone */ public function testAddTombstone() { $writer = new Writer\Feed(); $tombstone = $writer->createTombstone(); $writer->addTombstone($tombstone); $this->assertInstanceOf('Zend\\Feed\\Writer\\Deleted', $writer->getEntry(0)); }
public function testAddsAndOrdersEntriesByDateIfRequested() { $writer = new Writer\Feed(); $entry = $writer->createEntry(); $entry->setDateCreated(1234567890); $entry2 = $writer->createEntry(); $entry2->setDateCreated(1230000000); $writer->addEntry($entry); $writer->addEntry($entry2); $writer->orderByDate(); $this->assertEquals(1230000000, $writer->getEntry(1)->getDateCreated()->get(Date\Date::TIMESTAMP)); }
/** * Builds the desired feed * * @param string $title * @param string $description * @param array $items * * @return \Zend\Feed\Writer\Feed */ protected function buildFeed(Request $req, $title, $description, $url, $items) { $feed = new Feed(); $feed->setTitle($title); $feed->setDescription($description); $feed->setLink($url); $feed->setGenerator('Packagist'); foreach ($items as $item) { $entry = $feed->createEntry(); $this->populateEntry($entry, $item); $feed->addEntry($entry); } if ($req->getRequestFormat() == 'atom') { $feed->setFeedLink($req->getUri(), $req->getRequestFormat()); } if ($feed->count()) { $feed->setDateModified($feed->getEntry(0)->getDateModified()); } else { $feed->setDateModified(new \DateTime()); } return $feed; }