implement tests for site specific config

test that site directory config files are read correctly
correct Settings.php to pass tests
This commit is contained in:
norb 2021-01-11 16:38:35 +01:00
commit c2b13b2f86
4 changed files with 27 additions and 14 deletions

View file

@ -35,7 +35,7 @@ class SettingsTest extends TestCase
public function testLoad()
{
$cfg = $this->load('cfg');
$cfg = $this->init('cfg')->load();
$this->assertNotEmpty($cfg);
return $cfg;
}
@ -48,15 +48,24 @@ class SettingsTest extends TestCase
$this->assertEquals('test', $cfg->mode);
}
/**
*/
public function testSiteOverride()
{
$cfg = $this->init('cfg')->site('site')->load();
$this->assertEquals(42, $cfg->answer);
}
public function testTestingOverride()
{
$cfg = $this->load('cfg/testingOverride');
$cfg = $this->init('cfg/testingOverride')->load();
$this->assertEquals(42, $cfg->answer);
}
public function testLocalOverride()
{
$cfg = $this->load('cfg/localOverride');
$cfg = $this->init('cfg/localOverride')->load();
$this->assertEquals(42, $cfg->answer);
}
@ -73,7 +82,7 @@ class SettingsTest extends TestCase
$this->assertEquals($defaultName, $cfg->buildFileName());
}
private function load(string $dir)
private function init(string $dir)
{
return (new Settings())->appPath(dirname(__FILE__)."/$dir/")->load();
}

View file

@ -1,3 +1,4 @@
<?php return [
'mode' => 'test'
'mode' => 'test',
'answer' => false
];

View file

@ -0,0 +1,3 @@
<?php return [
'answer' => 42
];