2014-09-04 18:30:22 +02:00
|
|
|
<?php
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
|
|
|
namespace Tests\Icinga\Web;
|
|
|
|
|
|
|
|
use Mockery;
|
|
|
|
use Icinga\Application\Icinga;
|
|
|
|
use Icinga\Web\Widget\SearchDashboard;
|
|
|
|
use Icinga\Test\BaseTestCase;
|
|
|
|
|
|
|
|
class SearchDashboardTest extends BaseTestCase
|
|
|
|
{
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
parent::tearDown();
|
|
|
|
Mockery::close(); // Necessary because some tests run in a separate process
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setupIcingaMock(\Zend_Controller_Request_Abstract $request)
|
|
|
|
{
|
|
|
|
$moduleMock = Mockery::mock('Icinga\Application\Modules\Module');
|
|
|
|
$searchUrl = (object) array(
|
|
|
|
'title' => 'Hosts',
|
|
|
|
'url' => 'monitoring/list/hosts?sort=host_severity&limit=10'
|
|
|
|
);
|
|
|
|
$moduleMock->shouldReceive('getSearchUrls')->andReturn(array(
|
|
|
|
$searchUrl
|
|
|
|
));
|
|
|
|
|
|
|
|
$moduleManagerMock = Mockery::mock('Icinga\Application\Modules\Manager');
|
|
|
|
$moduleManagerMock->shouldReceive('getLoadedModules')->andReturn(array(
|
|
|
|
'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->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
|
|
|
|
|
|
|
|
Icinga::setApp($bootstrapMock, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException Zend_Controller_Action_Exception
|
|
|
|
*/
|
|
|
|
public function testFoo()
|
|
|
|
{
|
2014-09-04 19:35:31 +02:00
|
|
|
$dashboard = SearchDashboard::search('pending');
|
2014-09-04 18:30:22 +02:00
|
|
|
$dashboard->getPane('search')->removeComponents();
|
|
|
|
$dashboard->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWhetherLoadLoadsSearchDashletsFromModules()
|
|
|
|
{
|
2014-09-04 19:35:31 +02:00
|
|
|
$dashboard = SearchDashboard::search('pending');
|
2014-09-04 18:30:22 +02:00
|
|
|
|
|
|
|
$result = $dashboard->getPane('search')->hasComponent('Hosts: pending');
|
|
|
|
|
2014-09-04 19:35:31 +02:00
|
|
|
$this->assertTrue($result, 'Dashboard::search() could not load search dashlets from modules');
|
2014-09-04 18:30:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testWhetherLoadProvidesHint()
|
|
|
|
{
|
2014-09-04 19:35:31 +02:00
|
|
|
$dashboard = SearchDashboard::search('');
|
2014-09-04 18:30:22 +02:00
|
|
|
|
|
|
|
$result = $dashboard->getPane('search')->hasComponent('Ready to search');
|
|
|
|
|
2014-09-04 19:35:31 +02:00
|
|
|
$this->assertTrue($result, 'Dashboard::search() could not get hint for search');
|
2014-09-04 18:30:22 +02:00
|
|
|
}
|
|
|
|
}
|