From f6c323fcf1df4a1e47e13281dd8daa07d31b4237 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sat, 29 Aug 2015 21:46:57 +0200 Subject: [PATCH] Very basic unit testing --- tests/VideoDownloadTest.php | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/VideoDownloadTest.php diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php new file mode 100644 index 0000000..7e01706 --- /dev/null +++ b/tests/VideoDownloadTest.php @@ -0,0 +1,71 @@ + + * @license GNU General Public License http://www.gnu.org/licenses/gpl.html + * @link http://rudloff.pro + * */ + +require_once __DIR__.'/../common.php'; +require_once __DIR__.'/../download.php'; + +/** + * Unit tests for the VideoDownload class + * + * PHP Version 5.3.10 + * + * @category Youtube-dl + * @package Youtubedl + * @author Pierre Rudloff + * @license GNU General Public License http://www.gnu.org/licenses/gpl.html + * @link http://rudloff.pro + * */ +class VideoDownloadTest extends PHPUnit_Framework_TestCase +{ + static private $_testVideoURL = 'https://www.youtube.com/watch?v=RJJ6FCAXvKg'; + + /** + * Test getVersion function + * @return void + */ + public function testGetVersion() + { + $this->assertStringMatchesFormat('%i.%i.%i', VideoDownload::getVersion()); + } + + /** + * Test getUA function + * @return void + */ + public function testGetUA() + { + $this->assertStringStartsWith('Mozilla/', VideoDownload::getUA()); + } + + /** + * Test listExtractors funtion + * @return void + */ + public function testListExtractors() + { + $extractors = VideoDownload::listExtractors(); + $this->assertNotEmpty($extractors); + $this->assertInternalType('array', $extractors); + } + + /** + * Test getURL function + * @return void + */ + public function testGetURL() + { + $url = VideoDownload::getURL(self::$_testVideoURL); + $this->assertArrayHasKey('success', $url); + $this->assertArrayHasKey('url', $url); + } +}