Пример #1
0
        }
        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');
$t->diag('->fetch()');
$result = $mock->fetch('www.openpne.jp.feed.rss');
$t->is(count($result), 10, '->fetch() for www.openpne.jp is returns array that contains recently 10 RSS entries');
$t->is($result[0]['title'], 'OpenPNE 3.2RC1 リリースのお知らせ', '->fetch() returns RSS entries that contains valid title');
$t->is($result[1]['title'], '', '->fetch() returns RSS entries that contains empty title');