From bff164146b101a18392f22cd942ec1c9a8589628 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 11 Nov 2014 13:21:51 +0100 Subject: add youtube playlist support, fix #620, fix #618 --- tests/unit/fetcher/YoutubeFetcherTest.php | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/unit/fetcher/YoutubeFetcherTest.php (limited to 'tests') diff --git a/tests/unit/fetcher/YoutubeFetcherTest.php b/tests/unit/fetcher/YoutubeFetcherTest.php new file mode 100644 index 000000000..4adf734ba --- /dev/null +++ b/tests/unit/fetcher/YoutubeFetcherTest.php @@ -0,0 +1,68 @@ + + * @copyright Bernhard Posselt 2012, 2014 + */ + +namespace OCA\News\Fetcher; + +use \OCA\News\Db\Feed; + + +class YoutubeFetcherTest extends \PHPUnit_Framework_TestCase { + + private $fetcher; + private $feedFetcher; + + public function setUp() { + $this->feedFetcher = $this->getMockBuilder( + '\OCA\News\Fetcher\FeedFetcher') + ->disableOriginalConstructor() + ->getMock(); + $this->fetcher = new YoutubeFetcher($this->feedFetcher); + } + + + public function testCanHandleFails() { + $url = 'http://youtube.com'; + $this->assertFalse($this->fetcher->canHandle($url)); + } + + + public function testCanHandle() { + $url = 'http://youtube.com/test/?test=a&list=b&b=c'; + $this->assertTrue($this->fetcher->canHandle($url)); + } + + + public function testPlaylistUrl() { + $url = 'http://youtube.com/something/weird?a=b&list=sobo3&c=1'; + $transformedUrl = 'http://gdata.youtube.com/feeds/api/playlists/sobo3'; + $favicon = true; + $modified = 3; + $etag = 5; + $feed = new Feed(); + $feed->setUrl('http://google.de'); + $result = [$feed, []]; + + $this->feedFetcher->expects($this->once()) + ->method('fetch') + ->with( + $this->equalTo($transformedUrl), + $this->equalTo($favicon), + $this->equalTo($modified), + $this->equalTo($etag) + ) + ->will($this->returnValue($result)); + $feed = $this->fetcher->fetch($url, $favicon, $modified, $etag); + + $this->assertEquals($url, $result[0]->getUrl()); + } + + +} \ No newline at end of file -- cgit v1.2.3