forked from Athlon1600/youtube-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYouTubeTest.php
44 lines (33 loc) · 1.07 KB
/
YouTubeTest.php
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
<?php
namespace YouTube\Tests;
use YouTube\Browser;
use YouTube\Exception\YouTubeException;
use YouTube\YouTubeDownloader;
class YouTubeTest extends TestCase
{
public function test_browser_cookies(): void
{
$browser = new Browser();
// set cookies
$browser->get('https://httpbin.org/cookies/set?name=random_value');
// list cookies
$list = $browser->get('https://httpbin.org/cookies');
$this->assertStringContainsString('random_value', $list->body);
}
public function test_get_download_links(): void
{
$downloader = new YouTubeDownloader();
$ret = $downloader->getDownloadLinks(self::BUNNY_VIDEO_ID);
$this->assertGreaterThan(0, count($ret->getAllFormats()));
}
public function test_get_download_links_bad_video(): void
{
$downloader = new YouTubeDownloader();
try {
$downloader->getDownloadLinks(self::NOT_FOUND_VIDEO);
$this->fail();
} catch (YouTubeException $exception) {
$this->assertTrue(true);
}
}
}