. * *///}}} declare(strict_types=1); namespace rabe\Util\tests; use rabe\Util\Settings; use PHPUnit\Framework\TestCase; class SettingsTest extends TestCase { public function testConstruct() { $cfg = new Settings(); $this->assertNotEmpty($cfg); return $cfg; } /** * @depends testConstruct */ public function testLoadNoFile(Settings $cfg) { $this->expectException(\ErrorException::class); $cfg->load(); } /** */ private function appPath(Settings $cfg, ?string $dir='') { if (isset($dir)) $dir .= '/'; $path = dirname(__FILE__).'/cfg/'.$dir; $cfg->appPath($path); return $cfg; } /** * @depends testConstruct */ public function testLoad(Settings $cfg) { $cfg = $this->appPath($cfg)->load(); $this->assertNotEmpty($cfg); return $cfg; } /** * @depends testLoad */ public function testMode(Settings $cfg) { $this->assertEquals('test', $cfg->mode); } /** * @depends testConstruct */ public function testSiteOverride(Settings $cfg) { $cfg = $this->appPath($cfg)->site('site')->load(); $this->assertEquals(42, $cfg->answer); } /** * @depends testConstruct */ public function testTestingOverride(Settings $cfg) { $cfg = $this->appPath($cfg, 'testingOverride')->load(); $this->assertEquals(42, $cfg->answer); } /** * @depends testConstruct */ public function testLocalOverride(Settings $cfg) { $cfg = $this->appPath($cfg, 'localOverride')->load(); $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()); } } /* jEdit buffer local properties {{{ * :folding=explicit:collapseFolds=1: }}}*/