2022-07-10 21:05:27 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace RssBridge\Tests;
|
|
|
|
|
|
|
|
use Configuration;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
final class ConfigurationTest extends TestCase
|
|
|
|
{
|
2022-08-23 22:19:53 +03:00
|
|
|
public function testValueFromDefaultConfig()
|
2022-07-10 21:05:27 +03:00
|
|
|
{
|
|
|
|
Configuration::loadConfiguration();
|
|
|
|
$this->assertSame(null, Configuration::getConfig('foobar', ''));
|
|
|
|
$this->assertSame(null, Configuration::getConfig('foo', 'bar'));
|
|
|
|
$this->assertSame(null, Configuration::getConfig('cache', ''));
|
2022-08-23 22:19:53 +03:00
|
|
|
$this->assertSame('UTC', Configuration::getConfig('system', 'timezone'));
|
|
|
|
}
|
2022-07-10 21:05:27 +03:00
|
|
|
|
2022-08-23 22:19:53 +03:00
|
|
|
public function testValueFromCustomConfig()
|
|
|
|
{
|
|
|
|
Configuration::loadConfiguration(['system' => ['timezone' => 'Europe/Berlin']]);
|
|
|
|
$this->assertSame('Europe/Berlin', Configuration::getConfig('system', 'timezone'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testValueFromEnv()
|
|
|
|
{
|
2023-06-11 04:16:03 +03:00
|
|
|
$env = [
|
|
|
|
'RSSBRIDGE_system_timezone' => 'Europe/Berlin',
|
|
|
|
'RSSBRIDGE_SYSTEM_MESSAGE' => 'hello',
|
|
|
|
'RSSBRIDGE_system_enabled_bridges' => 'TwitterBridge,GettrBridge',
|
|
|
|
'RSSBRIDGE_system_enable_debug_mode' => 'true',
|
|
|
|
'RSSBRIDGE_fileCache_path' => '/tmp/kek',
|
|
|
|
];
|
|
|
|
Configuration::loadConfiguration([], $env);
|
2022-07-10 21:05:27 +03:00
|
|
|
$this->assertSame('Europe/Berlin', Configuration::getConfig('system', 'timezone'));
|
2023-06-11 04:16:03 +03:00
|
|
|
$this->assertSame('hello', Configuration::getConfig('system', 'message'));
|
|
|
|
$this->assertSame(true, Configuration::getConfig('system', 'enable_debug_mode'));
|
|
|
|
$this->assertSame('/tmp/kek', Configuration::getConfig('FileCache', 'path'));
|
|
|
|
$this->assertSame(['TwitterBridge', 'GettrBridge'], Configuration::getConfig('system', 'enabled_bridges'));
|
2022-07-10 21:05:27 +03:00
|
|
|
}
|
|
|
|
}
|