From 6e1ed0b0d33ce3f893397eeb25909269402cf6bd Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 18 Jul 2018 22:30:55 +0200 Subject: [PATCH] Fix tests (#5400) * Avoid argc side-effects * Fix undefined array keys in JITConfigAdapter::set() * Avoid argv side effects in ApiTest --- src/Core/Config/JITConfigAdapter.php | 7 +++++++ tests/ApiTest.php | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Core/Config/JITConfigAdapter.php b/src/Core/Config/JITConfigAdapter.php index 96e4305ea3..527c718ae0 100644 --- a/src/Core/Config/JITConfigAdapter.php +++ b/src/Core/Config/JITConfigAdapter.php @@ -96,6 +96,13 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter $stored = $this->get($cat, $k, null, true); + if (!isset($this->in_db[$cat])) { + $this->in_db[$cat] = []; + } + if (!isset($this->in_db[$cat][$k])) { + $this->in_db[$cat] = false; + } + if (($stored === $dbvalue) && $this->in_db[$cat][$k]) { return true; } diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 4e27290195..4d19994e35 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -68,6 +68,18 @@ class ApiTest extends DatabaseTest Config::set('system', 'theme', 'system_theme'); } + /** + * Cleanup variables used by tests. + */ + protected function tearDown() + { + parent::tearDown(); + + $app = get_app(); + $app->argc = 1; + $app->argv = ['home']; + } + /** * Assert that an user array contains expected keys. * @param array $user User array