Fix dashboard tests utilizing BaseTestCase::setupIcingaMock()

This commit is contained in:
Johannes Meyer 2014-09-09 10:21:37 +02:00
parent a5c027b77c
commit cee3c32fa5
2 changed files with 5 additions and 24 deletions

View File

@ -47,7 +47,7 @@ class DashboardTest extends BaseTestCase
Mockery::close(); // Necessary because some tests run in a separate process Mockery::close(); // Necessary because some tests run in a separate process
} }
protected function setupIcingaMock(\Zend_Controller_Request_Abstract $request) public function setUp()
{ {
$moduleMock = Mockery::mock('Icinga\Application\Modules\Module'); $moduleMock = Mockery::mock('Icinga\Application\Modules\Module');
$moduleMock->shouldReceive('getPaneItems')->andReturn(array( $moduleMock->shouldReceive('getPaneItems')->andReturn(array(
@ -59,14 +59,8 @@ class DashboardTest extends BaseTestCase
'test-module' => $moduleMock 'test-module' => $moduleMock
)); ));
$bootstrapMock = Mockery::mock('Icinga\Application\ApplicationBootstrap')->shouldDeferMissing(); $bootstrapMock = $this->setupIcingaMock();
$bootstrapMock->shouldReceive('getFrontController->getRequest')->andReturnUsing(
function () use ($request) { return $request; }
)->shouldReceive('getApplicationDir')->andReturn(self::$appDir);
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock); $bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
Icinga::setApp($bootstrapMock, true);
} }
public function testWhetherCreatePaneCreatesAPane() public function testWhetherCreatePaneCreatesAPane()

View File

@ -5,19 +5,12 @@
namespace Tests\Icinga\Web; namespace Tests\Icinga\Web;
use Mockery; use Mockery;
use Icinga\Application\Icinga;
use Icinga\Web\Widget\SearchDashboard;
use Icinga\Test\BaseTestCase; use Icinga\Test\BaseTestCase;
use Icinga\Web\Widget\SearchDashboard;
class SearchDashboardTest extends BaseTestCase class SearchDashboardTest extends BaseTestCase
{ {
public function tearDown() public function setUp()
{
parent::tearDown();
Mockery::close();
}
protected function setupIcingaMock(\Zend_Controller_Request_Abstract $request)
{ {
$moduleMock = Mockery::mock('Icinga\Application\Modules\Module'); $moduleMock = Mockery::mock('Icinga\Application\Modules\Module');
$searchUrl = (object) array( $searchUrl = (object) array(
@ -33,14 +26,8 @@ class SearchDashboardTest extends BaseTestCase
'test-module' => $moduleMock 'test-module' => $moduleMock
)); ));
$bootstrapMock = Mockery::mock('Icinga\Application\ApplicationBootstrap')->shouldDeferMissing(); $bootstrapMock = $this->setupIcingaMock();
$bootstrapMock->shouldReceive('getFrontController->getRequest')->andReturnUsing(
function () use ($request) { return $request; }
)->shouldReceive('getApplicationDir')->andReturn(self::$appDir);
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock); $bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
Icinga::setApp($bootstrapMock, true);
} }
/** /**