Exemplo n.º 1
0
 public function executeRssBox()
 {
     $fetcher = new opRssFetcher('UTF-8');
     $this->result = @$fetcher->fetch($this->gadget->getConfig('url'), true);
     if ($this->result) {
         $this->result[1] = array_slice($this->result[1], 0, 5);
     }
 }
Exemplo n.º 2
0
        $feed = new SimplePie();
        $feed->set_file(new SimplePie_File($filePath));
        $feed->set_cache_location(sfConfig::get('sf_cache_dir'));
        if (!@$feed->init()) {
            return false;
        }
        return $feed;
    }
    public static function calcFixtureFilePath($path)
    {
        return dirname(__FILE__) . '/../../fixtures/feeds/' . $path;
    }
}
//------------------------------------------------------------
$t->diag('opRssFetcher');
$instance = new opRssFetcher('UTF-8');
$mock = new opRssFetcherMock('UTF-8');
$t->diag('->__construct()');
$t->is($instance->charset, 'UTF-8', '__construct() sets the specified character set to its property');
$t->diag('->createSimplePieObject()');
$t->isa_ok($instance->createSimplePieObject('http://www.openpne.jp/'), 'SimplePie', '->createSimplePieObject() returns an instance of "SimplePie"');
$t->is($instance->createSimplePieObject('http://example.com/undefined.rss'), false, '->createSimplePieObject() returns false if the specified uri is 404');
$t->is($instance->createSimplePieObject('Invalid Format URI'), false, '->createSimplePieObject() returns false if the specified uri is wrong');
$t->diag('->getFeedTitle()');
$t->is($mock->getFeedTitle('www.openpne.jp.feed.rss'), 'OpenPNE', '->getFeedTitle() returns RSS feed title');
$t->is($mock->getFeedTitle('www.openpne.jp.feed.atom'), 'OpenPNE', '->getFeedTitle() returns Atom feed title');
$t->is($instance->getFeedTitle('http://example.com/undefined.rss'), false, '->getFeedTitle() returns false if the specified uri is 404');
$t->diag('->getFeedDescription()');
$t->is($mock->getFeedDescription('www.openpne.jp.feed.rss'), 'オープンソースのSNSエンジン OpenPNEプロジェクト', '->getFeedTitle() returns RSS feed description');
$t->is($mock->getFeedDescription('www.openpne.jp.feed.atom'), 'オープンソースのSNSエンジン OpenPNEプロジェクト', '->getFeedTitle() returns Atom feed description');
$t->is($instance->getFeedDescription('http://example.com/undefined.rss'), false, '->getFeedTitle() returns false if the specified uri is 404');