icingaweb2/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php

60 lines
1.9 KiB
PHP
Raw Normal View History

2014-09-04 18:30:22 +02:00
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt */
2014-09-04 18:30:22 +02:00
namespace Tests\Icinga\Web;
use Mockery;
use Icinga\Test\BaseTestCase;
use Icinga\Web\Widget\SearchDashboard;
2014-09-04 18:30:22 +02:00
class SearchDashboardTest extends BaseTestCase
{
public function setUp()
2014-09-04 18:30:22 +02:00
{
$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 = $this->setupIcingaMock();
2014-09-04 18:30:22 +02:00
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
}
/**
* @expectedException Zend_Controller_Action_Exception
*/
2014-11-20 12:48:05 +01:00
public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()
2014-09-04 18:30:22 +02:00
{
$dashboard = SearchDashboard::search('pending');
2014-11-20 12:48:05 +01:00
$dashboard->getPane('search')->removeDashlets();
2014-09-04 18:30:22 +02:00
$dashboard->render();
}
public function testWhetherSearchLoadsSearchDashletsFromModules()
2014-09-04 18:30:22 +02:00
{
$dashboard = SearchDashboard::search('pending');
2014-09-04 18:30:22 +02:00
2014-11-20 12:48:05 +01:00
$result = $dashboard->getPane('search')->hasDashlet('Hosts: pending');
2014-09-04 18:30:22 +02:00
$this->assertTrue($result, 'Dashboard::search() could not load search dashlets from modules');
2014-09-04 18:30:22 +02:00
}
public function testWhetherSearchProvidesHintWhenSearchStringIsEmpty()
2014-09-04 18:30:22 +02:00
{
$dashboard = SearchDashboard::search();
2014-09-04 18:30:22 +02:00
2014-11-20 12:48:05 +01:00
$result = $dashboard->getPane('search')->hasDashlet('Ready to search');
2014-09-04 18:30:22 +02:00
$this->assertTrue($result, 'Dashboard::search() could not get hint for search');
2014-09-04 18:30:22 +02:00
}
}