From 5e9768e0e7f512a33d708b5947e3c7cd741be9b3 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sun, 28 Apr 2019 15:52:01 +0200 Subject: [PATCH 1/3] fix: Validate config only after the options have been set To avoid an exception when default options are not valid but the new options are. --- classes/Config.php | 2 +- tests/ConfigTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/classes/Config.php b/classes/Config.php index 1e8e9a1..e302bf7 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -135,7 +135,6 @@ class Config { $this->applyOptions($options); $this->getEnv(); - $this->validateOptions(); } /** @@ -216,6 +215,7 @@ class Config if (is_file($file)) { $options = Yaml::parse(file_get_contents($file)); self::$instance = new self($options); + self::$instance->validateOptions(); } else { throw new Exception("Can't find config file at ".$file); } diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 6480521..7304ed0 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -41,6 +41,20 @@ class ConfigTest extends BaseTest $this->assertConfig($config); } + /** + * Test the getInstance function. + * + * @return void + */ + public function testGetInstanceFromScratch() + { + Config::destroyInstance(); + + $config = Config::getInstance(); + $this->assertEquals($config->convert, false); + $this->assertConfig($config); + } + /** * Assert that a Config object is correctly instantiated. * From b61287523db92d5cc79c47ee0f8c4a6e9129a205 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sun, 28 Apr 2019 15:57:21 +0200 Subject: [PATCH 2/3] refactor: StreamInterface::close() should not return anything --- classes/streams/YoutubeChunkStream.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/streams/YoutubeChunkStream.php b/classes/streams/YoutubeChunkStream.php index 25c3ea8..09f80dc 100644 --- a/classes/streams/YoutubeChunkStream.php +++ b/classes/streams/YoutubeChunkStream.php @@ -60,11 +60,11 @@ class YoutubeChunkStream implements StreamInterface /** * Closes the stream and any underlying resources. * - * @return mixed + * @return void */ public function close() { - return $this->response->getBody()->close(); + $this->response->getBody()->close(); } /** From 076241dedfde94d0247a8b15f6cca1a6a7d4ca46 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sun, 28 Apr 2019 15:59:03 +0200 Subject: [PATCH 3/3] build(yarn): 2.0.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e1760e..a792473 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alltube", "description": "HTML GUI for youtube-dl", - "version": "2.0.0", + "version": "2.0.1", "author": "Pierre Rudloff", "bugs": "https://github.com/Rudloff/alltube/issues", "dependencies": {