blob: f53958b8f7b20590d10e837dab927a161a253de0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
<?php
/**
* Nextcloud - 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\Tests\Unit\Fetcher;
use \OCA\News\Db\Feed;
use OCA\News\Fetcher\FeedFetcher;
use OCA\News\Fetcher\YoutubeFetcher;
use PHPUnit\Framework\TestCase;
class YoutubeFetcherTest extends TestCase
{
private $fetcher;
private $feedFetcher;
public function setUp()
{
$this->feedFetcher = $this->getMockBuilder(FeedFetcher::class)
->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());
}
}
|