summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-11-11 13:21:51 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2014-11-11 13:22:00 +0100
commitbff164146b101a18392f22cd942ec1c9a8589628 (patch)
treeaf4fe3e78cd0880656f0cbb4f2c4bdace35fea7b /tests
parentdf4cbdb81d6cf8ec532e099b44c9ec7d009f28c6 (diff)
add youtube playlist support, fix #620, fix #618
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/fetcher/YoutubeFetcherTest.php68
1 files changed, 68 insertions, 0 deletions
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 @@
+<?php
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @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