From 85fb3a54cd7372c651df4e26458acb8451f27c9a Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 10:45:16 +0200 Subject: [PATCH] Test for exceptions when creating config --- tests/ConfigTest.php | 11 +++++++++++ tests/VideoDownloadTest.php | 29 ++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 9e7e1d8..da6cdf7 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -42,6 +42,17 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertInternalType('string', $this->config->rtmpdump); } + /** + * Test the getInstance function with a missing config file. + * + * @return void + * @expectedException Exception + */ + public function testGetInstanceWithMissingFile() + { + Config::getInstance('foo'); + } + /** * Test the getInstance function with the CONVERT environment variable. * diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 8e5d705..55e5915 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -5,6 +5,7 @@ namespace Alltube\Test; use Alltube\VideoDownload; +use Alltube\Config; /** * Unit tests for the VideoDownload class. @@ -31,7 +32,33 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase */ protected function tearDown() { - \Alltube\Config::destroyInstance(); + Config::destroyInstance(); + } + + /** + * Test VideoDownload constructor with wrong youtube-dl path. + * + * @return void + * @expectedException Exception + */ + public function testConstructorWithMissingYoutubedl() + { + new VideoDownload( + new Config(['youtubedl'=>'foo']) + ); + } + + /** + * Test VideoDownload constructor with wrong Python path. + * + * @return void + * @expectedException Exception + */ + public function testConstructorWithMissingPython() + { + new VideoDownload( + new Config(['python'=>'foo']) + ); } /**