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
}
protected function setupIcingaMock(\Zend_Controller_Request_Abstract $request)
public function setUp()
{
$moduleMock = Mockery::mock('Icinga\Application\Modules\Module');
$moduleMock->shouldReceive('getPaneItems')->andReturn(array(
@ -59,14 +59,8 @@ class DashboardTest extends BaseTestCase
'test-module' => $moduleMock
));
$bootstrapMock = Mockery::mock('Icinga\Application\ApplicationBootstrap')->shouldDeferMissing();
$bootstrapMock->shouldReceive('getFrontController->getRequest')->andReturnUsing(
function () use ($request) { return $request; }
)->shouldReceive('getApplicationDir')->andReturn(self::$appDir);
$bootstrapMock = $this->setupIcingaMock();
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
Icinga::setApp($bootstrapMock, true);
}
public function testWhetherCreatePaneCreatesAPane()

View File

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