Fix unit DB Form unit tests broken by inspection

refs #9641
This commit is contained in:
Matthias Jentsch 2015-07-16 16:22:13 +02:00
parent e357960d1e
commit 6d209ee203

View File

@ -28,8 +28,8 @@ class DbBackendFormTest extends BaseTestCase
{ {
$this->setUpResourceFactoryMock(); $this->setUpResourceFactoryMock();
Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend') Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend')
->shouldReceive('select->where->count') ->shouldReceive('inspect')
->andReturn(2); ->andReturn(self::createInspector(false));
// Passing array(null) is required to make Mockery call the constructor... // Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null)); $form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null));
@ -54,8 +54,8 @@ class DbBackendFormTest extends BaseTestCase
{ {
$this->setUpResourceFactoryMock(); $this->setUpResourceFactoryMock();
Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend') Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend')
->shouldReceive('count') ->shouldReceive('inspect')
->andReturn(0); ->andReturn(self::createInspector(true));
// Passing array(null) is required to make Mockery call the constructor... // Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null)); $form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null));
@ -80,4 +80,21 @@ class DbBackendFormTest extends BaseTestCase
->shouldReceive('getResourceConfig') ->shouldReceive('getResourceConfig')
->andReturn(new ConfigObject()); ->andReturn(new ConfigObject());
} }
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);
}
} }