From ef366dc6d101edc8b5435b67c10ccbf0f2ef8e80 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 27 Dec 2016 00:36:30 +0100 Subject: [PATCH] Add tests for getM3uStream() --- tests/VideoDownloadTest.php | 43 +++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 5bb6af2..4cd580d 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -347,11 +347,50 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase /** * Test getAudioStream function with a M3U8 file. * + * @param string $url URL + * @param string $format Format + * * @return void * @expectedException Exception + * @dataProvider M3uUrlProvider */ - public function testGetAudioStreamM3uError() + public function testGetAudioStreamM3uError($url, $format) { - $this->download->getAudioStream('https://twitter.com/verge/status/813055465324056576/video/1', 'best'); + $this->download->getAudioStream($url, $format); + } + + /** + * Test getM3uStream function. + * + * @param string $url URL + * @param string $format Format + * + * @return void + * @dataProvider M3uUrlProvider + */ + public function testGetM3uStream($url, $format) + { + $video = $this->download->getJSON($url, $format); + $stream = $this->download->getM3uStream($video); + $this->assertInternalType('resource', $stream); + $this->assertFalse(feof($stream)); + } + + /** + * Test getM3uStream function without avconv. + * + * @param string $url URL + * @param string $format Format + * + * @return void + * @expectedException Exception + * @dataProvider M3uUrlProvider + */ + public function testGetM3uStreamAvconvError($url, $format) + { + $config = \Alltube\Config::getInstance(); + $config->avconv = 'foobar'; + $video = $this->download->getJSON($url, $format); + $this->download->getM3uStream($video); } }