test Exceptions

This commit is contained in:
Norbert Wagner 2021-01-14 13:53:02 +01:00
parent f18ea38350
commit 81c9247571
3 changed files with 16 additions and 1 deletions

View File

@ -314,7 +314,7 @@ class Settings implements \Iterator
{
if ( !isset( $this->settings[$name] ) )
{
throw new \Exception("Setting '$name' not found");
throw new \OutOfRangeException("Setting '$name' not found");
// todo: throw new SettingNotFoundException();
}

View File

@ -82,9 +82,20 @@ class SettingsTest extends TestCase
$this->assertIsObject($nested);
$this->assertIsIterable($nested);
$this->assertEquals(1, $nested->level);
$this->assertEquals(2, $nested->nested->level);
$this->assertEquals('default', $nested->testFiles);
}
/**
* @depends testLoad
*/
public function testSettingNotFound(Settings $cfg)
{
$this->assertEquals('default', $cfg->testFiles);
$this->expectException(\OutOfRangeException::class);
$cfg->keyDoesNotExist;
}
/**
*/
public function testSiteOverride()

View File

@ -6,5 +6,9 @@
[
'level' => 1,
'testFiles' => 'default',
'nested' =>
[
'level' => 2
]
]
];