Fix the DbBackendFormTest
Mock ResourceFactory in form tests fixes #6596
This commit is contained in:
parent
fd21ba4e4d
commit
8f1959833b
|
@ -26,10 +26,10 @@ class DbBackendFormTest extends BaseTestCase
|
|||
*/
|
||||
public function testValidBackendIsValid()
|
||||
{
|
||||
Mockery::mock('alias:Icinga\Authentication\UserBackend')
|
||||
->shouldReceive('create')->with('test', Mockery::type('\Zend_Config'))->andReturnUsing(
|
||||
function () { return Mockery::mock(array('count' => 1)); }
|
||||
);
|
||||
$this->setUpUserBackendMock()
|
||||
->shouldReceive('count')
|
||||
->andReturn(2);
|
||||
$this->setUpResourceFactoryMock();
|
||||
|
||||
$form = new DbBackendForm();
|
||||
$form->setBackendName('test');
|
||||
|
@ -49,10 +49,10 @@ class DbBackendFormTest extends BaseTestCase
|
|||
*/
|
||||
public function testInvalidBackendIsNotValid()
|
||||
{
|
||||
Mockery::mock('alias:Icinga\Authentication\UserBackend')
|
||||
->shouldReceive('create')->with('test', Mockery::type('\Zend_Config'))->andReturnUsing(
|
||||
function () { return Mockery::mock(array('count' => 0)); }
|
||||
);
|
||||
$this->setUpUserBackendMock()
|
||||
->shouldReceive('count')
|
||||
->andReturn(0);
|
||||
$this->setUpResourceFactoryMock();
|
||||
|
||||
$form = new DbBackendForm();
|
||||
$form->setBackendName('test');
|
||||
|
@ -65,4 +65,19 @@ class DbBackendFormTest extends BaseTestCase
|
|||
'DbBackendForm claims that an invalid authentication backend without users is valid'
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUpUserBackendMock()
|
||||
{
|
||||
return Mockery::mock('overload:Icinga\Authentication\Backend\DbUserBackend');
|
||||
}
|
||||
|
||||
protected function setUpResourceFactoryMock()
|
||||
{
|
||||
Mockery::mock('alias:Icinga\Data\ResourceFactory')
|
||||
->shouldReceive('getResourceConfig')
|
||||
->andReturn(new \Zend_Config(array()))
|
||||
->shouldReceive('createResource')
|
||||
->with(Mockery::type('\Zend_Config'))
|
||||
->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue