test: add new test for Configuration (#2915)

This commit is contained in:
Dag 2022-07-10 20:05:27 +02:00 committed by GitHub
parent c33f84fcc2
commit 5e52ecc3f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 4 deletions

View File

@ -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;

View File

@ -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);

View File

@ -78,7 +78,3 @@ spl_autoload_register(function ($className) {
}
}
});
Configuration::verifyInstallation();
Configuration::loadConfiguration();
Authentication::showPromptIfNeeded();

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace RssBridge\Tests;
use Configuration;
use PHPUnit\Framework\TestCase;
final class ConfigurationTest extends TestCase
{
public function test()
{
putenv('RSSBRIDGE_system_timezone=Europe/Berlin');
Configuration::loadConfiguration();
// test nonsense
$this->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'));
}
}