From d2ad962f6f644b321558810d9d0866f4ceacadf5 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 24 Apr 2017 18:07:59 +0200 Subject: [PATCH] Use cleaner way to create custom config everywhere --- tests/FrontControllerTest.php | 16 ++++++++++++---- tests/VideoDownloadTest.php | 20 ++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tests/FrontControllerTest.php b/tests/FrontControllerTest.php index db02b24..c1b64ce 100644 --- a/tests/FrontControllerTest.php +++ b/tests/FrontControllerTest.php @@ -83,6 +83,17 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase Config::destroyInstance(); } + /** + * Test the constructor. + * + * @return void + */ + public function testConstructor() + { + $controller = new FrontController($this->container); + $this->assertInstanceOf(FrontController::class, $controller); + } + /** * Test the constructor with streams enabled. * @@ -325,10 +336,7 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase */ public function testRedirectWithM3uStream() { - $config = Config::getInstance(); - $config->stream = true; - //We need to create a new controller instance in order to apply the custom config - $controller = new FrontController($this->container); + $controller = new FrontController($this->container, new Config(['stream'=>true])); $result = $controller->redirect( $this->request->withQueryParams(['url'=>'https://twitter.com/verge/status/813055465324056576/video/1']), $this->response diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 39119db..e207ef5 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -25,7 +25,7 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->download = new VideoDownload(); + $this->download = new VideoDownload(Config::getInstance('config_test.yml')); } /** @@ -321,9 +321,8 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase */ public function testGetAudioStreamAvconvError($url, $format) { - $config = Config::getInstance(); - $config->avconv = 'foobar'; - $this->download->getAudioStream($url, $format); + $download = new VideoDownload(new Config(['avconv'=>'foobar'])); + $download->getAudioStream($url, $format); } /** @@ -338,10 +337,8 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase */ public function testGetAudioStreamCurlError($url, $format) { - $config = Config::getInstance(); - $config->curl = 'foobar'; - $config->rtmpdump = 'foobar'; - $this->download->getAudioStream($url, $format); + $download = new VideoDownload(new Config(['curl'=>'foobar', 'rtmpdump'=>'foobar'])); + $download->getAudioStream($url, $format); } /** @@ -388,9 +385,8 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase */ public function testGetM3uStreamAvconvError($url, $format) { - $config = \Alltube\Config::getInstance(); - $config->avconv = 'foobar'; - $video = $this->download->getJSON($url, $format); - $this->download->getM3uStream($video); + $download = new VideoDownload(new Config(['avconv'=>'foobar'])); + $video = $download->getJSON($url, $format); + $download->getM3uStream($video); } }