Fix DbBackendFormTest not creating a valid ResourceFactory mock object

refs #7063
This commit is contained in:
Johannes Meyer 2014-09-03 10:00:41 +02:00
parent 8e5deb8029
commit 3f9cb00b1f
1 changed files with 5 additions and 13 deletions

View File

@ -26,10 +26,10 @@ class DbBackendFormTest extends BaseTestCase
*/ */
public function testValidBackendIsValid() public function testValidBackendIsValid()
{ {
$this->setUpUserBackendMock() $this->setUpResourceFactoryMock();
Mockery::mock('overload:Icinga\Authentication\Backend\DbUserBackend')
->shouldReceive('count') ->shouldReceive('count')
->andReturn(2); ->andReturn(2);
$this->setUpResourceFactoryMock();
$form = new DbBackendForm(); $form = new DbBackendForm();
$form->setBackendName('test'); $form->setBackendName('test');
@ -49,10 +49,10 @@ class DbBackendFormTest extends BaseTestCase
*/ */
public function testInvalidBackendIsNotValid() public function testInvalidBackendIsNotValid()
{ {
$this->setUpUserBackendMock() $this->setUpResourceFactoryMock();
Mockery::mock('overload:Icinga\Authentication\Backend\DbUserBackend')
->shouldReceive('count') ->shouldReceive('count')
->andReturn(0); ->andReturn(0);
$this->setUpResourceFactoryMock();
$form = new DbBackendForm(); $form = new DbBackendForm();
$form->setBackendName('test'); $form->setBackendName('test');
@ -66,18 +66,10 @@ class DbBackendFormTest extends BaseTestCase
); );
} }
protected function setUpUserBackendMock()
{
return Mockery::mock('overload:Icinga\Authentication\Backend\DbUserBackend');
}
protected function setUpResourceFactoryMock() protected function setUpResourceFactoryMock()
{ {
Mockery::mock('alias:Icinga\Data\ResourceFactory') Mockery::mock('alias:Icinga\Data\ResourceFactory')
->shouldReceive('getResourceConfig') ->shouldReceive('create')
->andReturn(new \Zend_Config(array()))
->shouldReceive('createResource')
->with(Mockery::type('\Zend_Config'))
->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection')); ->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection'));
} }
} }