2020-05-28 11:54:21 -05:00
|
|
|
<?php
|
|
|
|
namespace Aerex\BaikalStorage;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Aerex\BaikalStorage\Configs\ConfigBuilder;
|
2020-05-29 11:45:53 -05:00
|
|
|
use Aerex\BaikalStorage\Configs\TaskwarriorConfig;
|
2020-05-28 11:54:21 -05:00
|
|
|
|
|
|
|
class ConfigTest extends TestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \PHPUnit_Framework_MockObject_MockObject
|
|
|
|
* */
|
|
|
|
|
|
|
|
public $mockConfigBuilder;
|
|
|
|
|
2020-06-03 00:04:43 -05:00
|
|
|
public function testGeneralLoggerConfigs() {
|
2020-05-28 11:54:21 -05:00
|
|
|
$configs = new ConfigBuilder(__DIR__ . '/Fixtures/LoggerConfig.yaml');
|
|
|
|
$contents = $configs->loadYaml();
|
|
|
|
$this->assertEquals(sizeof($contents), 1);
|
2020-06-03 00:04:43 -05:00
|
|
|
$this->assertArrayHasKey('general', $contents, 'config missing general config');
|
|
|
|
$generalConfigs = $contents['general'];
|
|
|
|
$this->assertArrayHasKey('logger', $generalConfigs, 'general config is missing logger property');
|
|
|
|
$this->assertArrayHasKey('file', $generalConfigs['logger'], 'general logger config missing file property');
|
|
|
|
$this->assertEquals($generalConfigs['logger']['file'], '/home/user/logger.yaml');
|
|
|
|
$this->assertArrayHasKey('level', $generalConfigs['logger'], 'general logger config missing level property');
|
|
|
|
$this->assertEquals($generalConfigs['logger']['level'], 'ERROR', 'ERROR is not set as default logger level');
|
|
|
|
$this->assertArrayHasKey('enabled', $generalConfigs['logger'], 'general config logger enabled property is missing');
|
|
|
|
$this->assertTrue($generalConfigs['logger']['enabled']);
|
|
|
|
$this->assertArrayHasKey('timezone', $generalConfigs, 'general config is missing timezone property');
|
|
|
|
$this->assertEquals($generalConfigs['timezone'], 'UTC', 'UTC is not set as default timezone');
|
2020-05-28 11:54:21 -05:00
|
|
|
}
|
|
|
|
|
2020-05-29 11:45:53 -05:00
|
|
|
public function testTaskwarriorConfig() {
|
|
|
|
$configs = new ConfigBuilder(__DIR__ . '/Fixtures/TaskwarriorConfig.yaml');
|
|
|
|
$configs->add(new TaskwarriorConfig());
|
|
|
|
$contents = $configs->loadYaml();
|
|
|
|
$this->assertEquals(sizeof($contents), 2);
|
2020-06-03 00:04:43 -05:00
|
|
|
$this->assertArrayHasKey('storages', $contents, 'storages config missing');
|
|
|
|
$this->assertArrayHasKey('taskwarrior', $contents['storages'], 'storage config missing taskwarrior property');
|
|
|
|
$taskwarriorConfigs = $contents['storages']['taskwarrior'];
|
|
|
|
$this->assertArrayHasKey('taskrc', $taskwarriorConfigs, 'taskwarrior config is missing taskrc property');
|
|
|
|
$this->assertEquals($taskwarriorConfigs['taskrc'], '/home/aerex/.taskrc');
|
|
|
|
$this->assertArrayHasKey('taskdata', $taskwarriorConfigs, 'taskwarrior config is missing taskdata property');
|
|
|
|
$this->assertEquals($taskwarriorConfigs['taskdata'], '/home/aerex/.task');
|
|
|
|
$this->assertArrayHasKey('project_tag_suffix', $taskwarriorConfigs, 'taskwarrior config is missing project_tag_suffix property');
|
|
|
|
$this->assertEquals($taskwarriorConfigs['project_tag_suffix'], 'project_');
|
2020-05-29 11:45:53 -05:00
|
|
|
}
|
2020-05-28 11:54:21 -05:00
|
|
|
}
|
|
|
|
|