mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-27 03:50:42 +03:00
0a8fe57003
* refactor: bridgefactory, add tests * refactor: move defaultly enabled bridges to config * refactor * refactor * feat: add support for enabling bridges with env var
43 lines
1.7 KiB
PHP
43 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace RssBridge\Tests;
|
|
|
|
use Configuration;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ConfigurationTest extends TestCase
|
|
{
|
|
public function testValueFromDefaultConfig()
|
|
{
|
|
Configuration::loadConfiguration();
|
|
$this->assertSame(null, Configuration::getConfig('foobar', ''));
|
|
$this->assertSame(null, Configuration::getConfig('foo', 'bar'));
|
|
$this->assertSame(null, Configuration::getConfig('cache', ''));
|
|
$this->assertSame('UTC', Configuration::getConfig('system', 'timezone'));
|
|
}
|
|
|
|
public function testValueFromCustomConfig()
|
|
{
|
|
Configuration::loadConfiguration(['system' => ['timezone' => 'Europe/Berlin']]);
|
|
$this->assertSame('Europe/Berlin', Configuration::getConfig('system', 'timezone'));
|
|
}
|
|
|
|
public function testValueFromEnv()
|
|
{
|
|
$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);
|
|
$this->assertSame('Europe/Berlin', Configuration::getConfig('system', 'timezone'));
|
|
$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'));
|
|
}
|
|
}
|