. * *///}}} declare(strict_types=1); namespace rabe\Util\tests; use rabe\Util\Settings; use PHPUnit\Framework\TestCase; class SettingsTest extends TestCase { public function testLoadNoFile() { $this->expectException(\ErrorException::class); (new Settings())->load(); } public function testLoad() { $cfg = $this->load('cfg'); $this->assertNotEmpty($cfg); return $cfg; } /** * @depends testLoad */ public function testMode(Settings $cfg) { $this->assertEquals('test', $cfg->mode); } public function testTestingOverride() { $cfg = $this->load('cfg/testingOverride'); $this->assertEquals(42, $cfg->answer); } public function testLocalOverride() { $cfg = $this->load('cfg/localOverride'); $this->assertEquals(42, $cfg->answer); } public function testBuildFileName() { $path = './config/'; $prefix = ''; $postfix = 'conf.php'; $type = ''; $defaultName = "$path$prefix$type$postfix"; $cfg = new Settings(); $this->assertEquals($defaultName, $cfg->buildFileName()); } private function load(string $dir) { return (new Settings())->appPath(dirname(__FILE__)."/$dir/")->load(); } } /* jEdit buffer local properties {{{ * :folding=explicit:collapseFolds=1: }}}*/