Example #1
0
 protected function onRss(Rss $rss)
 {
     $item = $rss->current();
     $this->testCase->assertEquals('Star City', $item->getTitle());
     $this->testCase->assertEquals('http://liftoff.msfc.nasa.gov/2003/06/03.html#item573', $item->getGuid());
     $this->testCase->assertEquals('2003-06-03 09:39:21', $item->getPubDate()->format('Y-m-d H:i:s'));
     $this->testCase->assertEquals('foobar', $item->getDescription());
 }
Example #2
0
 public function getRssRecord()
 {
     $rss = new RssRecord();
     $rss->setTitle('Liftoff News');
     $rss->setLink('http://liftoff.msfc.nasa.gov/');
     $rss->setDescription('Liftoff to Space Exploration.');
     $rss->setLanguage('en-us');
     $rss->setPubDate(new DateTime('Tue, 10 Jun 2003 04:00:00 GMT'));
     $rss->setLastBuildDate(new DateTime('Tue, 10 Jun 2003 09:41:01 GMT'));
     $rss->setDocs('http://blogs.law.harvard.edu/tech/rss');
     $rss->setGenerator('Weblog Editor 2.0');
     $rss->setManagingEditor('*****@*****.**');
     $rss->setWebMaster('*****@*****.**');
     $rss->add($this->getItemRecord());
     return $rss;
 }
Example #3
0
File: Rss.php Project: seytar/psx
 protected function buildChannel(RssRecord $rss, Writer $writer)
 {
     $language = $rss->getLanguage();
     if (!empty($language)) {
         $writer->setLanguage($language);
     }
     $copyright = $rss->getCopyright();
     if (!empty($copyright)) {
         $writer->setCopyright($copyright);
     }
     $managingEditor = $rss->getManagingEditor();
     if (!empty($managingEditor)) {
         $writer->setManagingEditor($managingEditor);
     }
     $webMaster = $rss->getWebMaster();
     if (!empty($webMaster)) {
         $writer->setWebMaster($webMaster);
     }
     $pubDate = $rss->getPubDate();
     if ($pubDate instanceof DateTime) {
         $writer->setPubDate($pubDate);
     }
     $lastBuildDate = $rss->getLastBuildDate();
     if ($lastBuildDate instanceof DateTime) {
         $writer->setLastBuildDate($lastBuildDate);
     }
     $categories = $rss->getCategory();
     if (is_array($categories)) {
         foreach ($categories as $category) {
             $writer->addCategory($category->getText(), $category->getDomain());
         }
     }
     $generator = $rss->getGenerator();
     if (!empty($generator)) {
         $writer->setGenerator($generator);
     }
     $docs = $rss->getDocs();
     if (!empty($docs)) {
         $writer->setDocs($docs);
     }
     $cloud = $rss->getCloud();
     if ($cloud instanceof Cloud) {
         $writer->setCloud($cloud->getDomain(), $cloud->getPort(), $cloud->getPath(), $cloud->getRegisterProcedure(), $cloud->getProtocol());
     }
     $ttl = $rss->getTtl();
     if (!empty($ttl)) {
         $writer->setTtl($ttl);
     }
     $rating = $rss->getRating();
     if (!empty($rating)) {
         $writer->setRating($rating);
     }
     $skipHours = $rss->getSkipHours();
     if (!empty($skipHours)) {
         $writer->setSkipHours($skipHours);
     }
     $skipDays = $rss->getSkipDays();
     if (!empty($skipDays)) {
         $writer->setSkipDays($skipDays);
     }
 }
Example #4
0
    public function testSerialize()
    {
        $item = new Item();
        $item->setTitle('Star City');
        $item->setLink('http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp');
        $item->setDescription('How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia\'s <a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm">Star City</a>.');
        $item->setAuthor('foobar');
        $item->addCategory(new Category('Newspapers'));
        $item->setComments('http://localhost.com#comments');
        $item->setEnclosure(new Enclosure('http://www.scripting.com/mp3s/weatherReportSuite.mp3', 12216320, 'audio/mpeg'));
        $item->setGuid('http://liftoff.msfc.nasa.gov/2003/06/03.html#item573');
        $item->setPubDate(new DateTime('Tue, 03 Jun 2003 09:39:21 GMT'));
        $item->setSource('Tomalaks Realm');
        $rss = new Rss();
        $rss->setTitle('Liftoff News');
        $rss->setLink('http://liftoff.msfc.nasa.gov/');
        $rss->setDescription('Liftoff to Space Exploration.');
        $rss->setLanguage('en-us');
        $rss->setCopyright('2014 foobar');
        $rss->setManagingEditor('*****@*****.**');
        $rss->setWebMaster('*****@*****.**');
        $rss->setGenerator('Weblog Editor 2.0');
        $rss->setDocs('http://blogs.law.harvard.edu/tech/rss');
        $rss->setTtl(60);
        $rss->setImage('http://localhost.com/image.png');
        $rss->setRating('en');
        $rss->setSkipHours(20);
        $rss->setSkipDays('Tuesday');
        $rss->addCategory(new Category('Newspapers'));
        $rss->setPubDate(new DateTime('Tue, 10 Jun 2003 04:00:00 GMT'));
        $rss->setLastBuildDate(new DateTime('Tue, 10 Jun 2003 09:41:01 GMT'));
        $rss->setCloud(new Cloud('rpc.sys.com', 80, '/RPC2', 'pingMe', 'soap'));
        $rss->add($item);
        $content = <<<JSON
{
  "title": "Liftoff News",
  "link": "http://liftoff.msfc.nasa.gov/",
  "description": "Liftoff to Space Exploration.",
  "language": "en-us",
  "copyright": "2014 foobar",
  "managingEditor": "*****@*****.**",
  "webMaster": "*****@*****.**",
  "generator": "Weblog Editor 2.0",
  "docs": "http://blogs.law.harvard.edu/tech/rss",
  "ttl": 60,
  "image": "http://localhost.com/image.png",
  "rating": "en",
  "skipHours": 20,
  "skipDays": "Tuesday",
  "category": [{
  \t"text": "Newspapers"
  }],
  "pubDate": "2003-06-10T04:00:00Z",
  "lastBuildDate": "2003-06-10T09:41:01Z",
  "cloud": {
    "domain": "rpc.sys.com",
    "port": 80,
    "path": "/RPC2",
    "registerProcedure": "pingMe",
    "protocol": "soap"
  },
  "item": [{
    "title": "Star City",
    "link": "http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp",
    "description": "How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's <a href=\\"http://howe.iki.rssi.ru/GCTC/gctc_e.htm\\">Star City</a>.",
    "author": "foobar",
    "category": [{
    \t"text": "Newspapers"
    }],
    "guid": "http://liftoff.msfc.nasa.gov/2003/06/03.html#item573",
    "pubDate": "2003-06-03T09:39:21Z",
    "comments": "http://localhost.com#comments",
    "enclosure": {
      "url": "http://www.scripting.com/mp3s/weatherReportSuite.mp3",
      "length": 12216320,
      "type": "audio/mpeg"
    },
    "source": "Tomalaks Realm"
  }]
}
JSON;
        $this->assertRecordEqualsContent($rss, $content);
    }