コード例 #1
0
ファイル: FeedTest.php プロジェクト: pnaq57/zf2demo
 /**
  * @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));
 }
コード例 #2
0
ファイル: FeedTest.php プロジェクト: narixx/zf2
 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));
 }
コード例 #3
0
 /**
  * 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;
 }