Skip to content

Commit

Permalink
Added: test for duration
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Dec 17, 2017
1 parent 1b91219 commit 4dd1d5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/TroiaStudio/Utils/Youtube-API/Reader.php
Expand Up @@ -164,6 +164,7 @@ private function createVideo($data, $videoId)
$video->url = 'https://www.youtube.com/watch?v=' . $videoId;
$video->embed = 'https://www.youtube.com/embed/' . $videoId;
$video->views = $statistics->viewCount;
$video->duration = $details->duration;


$video->published = new Nette\Utils\DateTime($snippet->publishedAt);
Expand Down
7 changes: 4 additions & 3 deletions tests/TroiaStudio/YoutubeAPI/Reader.phpt
Expand Up @@ -7,8 +7,9 @@ $config = parse_ini_file(__DIR__ . '/../../php.ini');
$apiKey = $config['YT_TOKEN'];

$reader = new TroiaStudio\YoutubeAPI\Reader($apiKey);
$video = $reader->getVideo('https://youtu.be/HxfhTDu72VI');
$video = $reader->getVideo('https://youtu.be/kiKZau6XoSc');

Assert::true($video instanceof TroiaStudio\YoutubeAPI\Video);
Assert::same('https://www.youtube.com/watch?v=HxfhTDu72VI', $video->url);
Assert::same('https://www.youtube.com/embed/HxfhTDu72VI', $video->embed);
Assert::same('https://www.youtube.com/watch?v=kiKZau6XoSc', $video->url);
Assert::same('https://www.youtube.com/embed/kiKZau6XoSc', $video->embed);
Assert::same('PT1M35S', $video->duration);
1 change: 1 addition & 0 deletions tests/php-win.ini
@@ -1,6 +1,7 @@
[PHP]
;extension_dir = "./ext"
extension=php_curl.dll
extension=php_openssl.dll

[TESTS]
YT_TOKEN=__PUT_HERE_YOUR_GOOGLE_API_KEY__

0 comments on commit 4dd1d5f

Please sign in to comment.