test Exceptions
This commit is contained in:
parent
f18ea38350
commit
81c9247571
3 changed files with 16 additions and 1 deletions
|
|
@ -314,7 +314,7 @@ class Settings implements \Iterator
|
||||||
{
|
{
|
||||||
if ( !isset( $this->settings[$name] ) )
|
if ( !isset( $this->settings[$name] ) )
|
||||||
{
|
{
|
||||||
throw new \Exception("Setting '$name' not found");
|
throw new \OutOfRangeException("Setting '$name' not found");
|
||||||
// todo: throw new SettingNotFoundException();
|
// todo: throw new SettingNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,20 @@ class SettingsTest extends TestCase
|
||||||
$this->assertIsObject($nested);
|
$this->assertIsObject($nested);
|
||||||
$this->assertIsIterable($nested);
|
$this->assertIsIterable($nested);
|
||||||
$this->assertEquals(1, $nested->level);
|
$this->assertEquals(1, $nested->level);
|
||||||
|
$this->assertEquals(2, $nested->nested->level);
|
||||||
$this->assertEquals('default', $nested->testFiles);
|
$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()
|
public function testSiteOverride()
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,9 @@
|
||||||
[
|
[
|
||||||
'level' => 1,
|
'level' => 1,
|
||||||
'testFiles' => 'default',
|
'testFiles' => 'default',
|
||||||
|
'nested' =>
|
||||||
|
[
|
||||||
|
'level' => 2
|
||||||
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue