From 5e52ecc3f8c117354fe172523879abf3783ffce9 Mon Sep 17 00:00:00 2001 From: Dag Date: Sun, 10 Jul 2022 20:05:27 +0200 Subject: [PATCH] test: add new test for Configuration (#2915) --- .../prepare_release/fetch_contributors.php | 2 ++ index.php | 4 +++ lib/rssbridge.php | 4 --- tests/ConfigurationTest.php | 31 +++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/ConfigurationTest.php diff --git a/contrib/prepare_release/fetch_contributors.php b/contrib/prepare_release/fetch_contributors.php index 80de72a5..724d9fd1 100644 --- a/contrib/prepare_release/fetch_contributors.php +++ b/contrib/prepare_release/fetch_contributors.php @@ -4,6 +4,8 @@ require __DIR__ . '/../../lib/rssbridge.php'; +Configuration::loadConfiguration(); + $url = 'https://api.github.com/repos/rss-bridge/rss-bridge/contributors'; $contributors = []; $next = true; diff --git a/index.php b/index.php index fe1ed882..9eaa17a6 100644 --- a/index.php +++ b/index.php @@ -2,6 +2,10 @@ require_once __DIR__ . '/lib/rssbridge.php'; +Configuration::verifyInstallation(); +Configuration::loadConfiguration(); +Authentication::showPromptIfNeeded(); + try { if (isset($argv)) { parse_str(implode('&', array_slice($argv, 1)), $cliArgs); diff --git a/lib/rssbridge.php b/lib/rssbridge.php index 33f9bf06..d900c910 100644 --- a/lib/rssbridge.php +++ b/lib/rssbridge.php @@ -78,7 +78,3 @@ spl_autoload_register(function ($className) { } } }); - -Configuration::verifyInstallation(); -Configuration::loadConfiguration(); -Authentication::showPromptIfNeeded(); diff --git a/tests/ConfigurationTest.php b/tests/ConfigurationTest.php new file mode 100644 index 00000000..6a5dce26 --- /dev/null +++ b/tests/ConfigurationTest.php @@ -0,0 +1,31 @@ +assertSame(null, Configuration::getConfig('foobar', '')); + $this->assertSame(null, Configuration::getConfig('foo', 'bar')); + $this->assertSame(null, Configuration::getConfig('cache', '')); + + // test value from env + $this->assertSame('Europe/Berlin', Configuration::getConfig('system', 'timezone')); + + // test real values + $this->assertSame('file', Configuration::getConfig('cache', 'type')); + $this->assertSame(false, Configuration::getConfig('authentication', 'enable')); + $this->assertSame(true, Configuration::getConfig('admin', 'donations')); + $this->assertSame(1, Configuration::getConfig('error', 'report_limit')); + } +}