parent
f4054d575b
commit
31618ce2cf
|
@ -26,7 +26,7 @@ class DbResourceFormTest extends BaseTestCase
|
|||
public function testValidDbResourceIsValid()
|
||||
{
|
||||
$this->setUpResourceFactoryMock(
|
||||
Mockery::mock()->shouldReceive('getConnection')->atMost()->twice()->andReturn(Mockery::self())->getMock()
|
||||
Mockery::mock()->shouldReceive('inspect')->andReturn(self::createInspector(false))->getMock()
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
|
@ -42,7 +42,7 @@ class DbResourceFormTest extends BaseTestCase
|
|||
public function testInvalidDbResourceIsNotValid()
|
||||
{
|
||||
$this->setUpResourceFactoryMock(
|
||||
Mockery::mock()->shouldReceive('getConnection')->once()->andThrow('\Exception')->getMock()
|
||||
Mockery::mock()->shouldReceive('inspect')->andReturn(self::createInspector(true))->getMock()
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
|
@ -58,4 +58,21 @@ class DbResourceFormTest extends BaseTestCase
|
|||
->with(Mockery::type('Icinga\Data\ConfigObject'))
|
||||
->andReturn($resourceMock);
|
||||
}
|
||||
|
||||
public static function createInspector($error = false, $log = array('log'))
|
||||
{
|
||||
if (! $error) {
|
||||
$calls = array(
|
||||
'hasError' => false,
|
||||
'toArray' => $log
|
||||
);
|
||||
} else {
|
||||
$calls = array(
|
||||
'hasError' => true,
|
||||
'getError' => 'Error',
|
||||
'toArray' => $log
|
||||
);
|
||||
}
|
||||
return Mockery::mock('Icinga\Data\Inspection', $calls);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue