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()
|
|
|
|
{
|
|
|
|
putenv('RSSBRIDGE_system_timezone=Europe/Berlin');
|
|
|
|
putenv('RSSBRIDGE_TwitterV2Bridge_twitterv2apitoken=aaa');
|
|
|
|
putenv('RSSBRIDGE_SQLiteCache_file=bbb');
|
|
|
|
Configuration::loadConfiguration([], getenv());
|
2022-07-10 21:05:27 +03:00
|
|
|
$this->assertSame('Europe/Berlin', Configuration::getConfig('system', 'timezone'));
|
2022-08-23 22:19:53 +03:00
|
|
|
$this->assertSame('aaa', Configuration::getConfig('TwitterV2Bridge', 'twitterv2apitoken'));
|
|
|
|
$this->assertSame('bbb', Configuration::getConfig('SQLiteCache', 'file'));
|
|
|
|
$this->assertSame('bbb', Configuration::getConfig('sqlitecache', 'file'));
|
2022-07-10 21:05:27 +03:00
|
|
|
}
|
|
|
|
}
|