mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-24 10:27:46 +02:00
SearchDashboardTest: Adjust unit tests according to the new dashboards
This commit is contained in:
parent
af4d9c8257
commit
c773ad3ac7
@ -43,7 +43,7 @@ class DashletManager
|
|||||||
{
|
{
|
||||||
$query = Model\ModuleDashlet::on(DBUtils::getConn())
|
$query = Model\ModuleDashlet::on(DBUtils::getConn())
|
||||||
->disableDefaultSort()
|
->disableDefaultSort()
|
||||||
->setColumns([new Expression('1')])
|
->columns([new Expression('1')])
|
||||||
->filter(Filter::equal('id', $dashlet->getUuid()));
|
->filter(Filter::equal('id', $dashlet->getUuid()));
|
||||||
|
|
||||||
return $query->execute()->hasResult();
|
return $query->execute()->hasResult();
|
||||||
|
@ -71,7 +71,7 @@ trait DashboardUserManager
|
|||||||
public static function userExist(): bool
|
public static function userExist(): bool
|
||||||
{
|
{
|
||||||
$query = DashboardOwner::on(DBUtils::getConn())
|
$query = DashboardOwner::on(DBUtils::getConn())
|
||||||
->setColumns(['id'])
|
->columns(['id'])
|
||||||
->filter(Filter::equal('username', self::getUser()->getUsername()));
|
->filter(Filter::equal('username', self::getUser()->getUsername()));
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
|
@ -4,12 +4,11 @@
|
|||||||
namespace Tests\Icinga\Web;
|
namespace Tests\Icinga\Web;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Authentication\Role;
|
use Icinga\Exception\Http\HttpNotFoundException;
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseDashboardTestCase;
|
||||||
use Icinga\User;
|
|
||||||
use Icinga\Web\Widget\SearchDashboard;
|
use Icinga\Web\Widget\SearchDashboard;
|
||||||
|
|
||||||
class SearchDashboardTest extends BaseTestCase
|
class SearchDashboardTest extends BaseDashboardTestCase
|
||||||
{
|
{
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
@ -23,48 +22,38 @@ class SearchDashboardTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()
|
public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()
|
||||||
{
|
{
|
||||||
$this->expectException(\Zend_Controller_Action_Exception::class);
|
$this->expectException(HttpNotFoundException::class);
|
||||||
|
|
||||||
$user = new User('test');
|
|
||||||
$user->setPermissions(array('*' => '*'));
|
|
||||||
$dashboard = new SearchDashboard();
|
$dashboard = new SearchDashboard();
|
||||||
$dashboard->setUser($user);
|
$dashboard->setUser($this->getUser());
|
||||||
$dashboard = $dashboard->search('pending');
|
$dashboard->search('pending');
|
||||||
$dashboard->getPane('search')->removeDashlets();
|
|
||||||
|
$searchHome = $dashboard->getActiveHome();
|
||||||
|
$searchHome->getEntry(SearchDashboard::SEARCH_PANE)->setEntries([]);
|
||||||
$dashboard->render();
|
$dashboard->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhetherSearchLoadsSearchDashletsFromModules()
|
public function testWhetherSearchLoadsSearchDashletsFromModules()
|
||||||
{
|
{
|
||||||
$role = new Role();
|
|
||||||
$role->setPermissions(['*']);
|
|
||||||
|
|
||||||
$user = new User('test');
|
|
||||||
$user->setRoles([$role]);
|
|
||||||
|
|
||||||
$dashboard = new SearchDashboard();
|
$dashboard = new SearchDashboard();
|
||||||
$dashboard->setUser($user);
|
$dashboard->setUser($this->getUser());
|
||||||
$dashboard = $dashboard->search('pending');
|
$dashboard->search('pending');
|
||||||
|
|
||||||
$result = $dashboard->getPane('search')->hasDashlet('Hosts: pending');
|
$searchHome = $dashboard->getActiveHome();
|
||||||
|
$result = $searchHome->getEntry(SearchDashboard::SEARCH_PANE)->hasEntry('Hosts: pending');
|
||||||
|
|
||||||
$this->assertTrue($result, 'Dashboard::search() could not load search dashlets from modules');
|
$this->assertTrue($result, 'SearchDashboard::search() could not load search dashlets from modules');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhetherSearchProvidesHintWhenSearchStringIsEmpty()
|
public function testWhetherSearchProvidesHintWhenSearchStringIsEmpty()
|
||||||
{
|
{
|
||||||
$role = new Role();
|
|
||||||
$role->setPermissions(['*']);
|
|
||||||
|
|
||||||
$user = new User('test');
|
|
||||||
$user->setRoles([$role]);
|
|
||||||
|
|
||||||
$dashboard = new SearchDashboard();
|
$dashboard = new SearchDashboard();
|
||||||
$dashboard->setUser($user);
|
$dashboard->setUser($this->getUser());
|
||||||
$dashboard = $dashboard->search();
|
$dashboard->search();
|
||||||
|
|
||||||
$result = $dashboard->getPane('search')->hasDashlet('Ready to search');
|
$searchHome = $dashboard->getActiveHome();
|
||||||
|
$result = $searchHome->getEntry(SearchDashboard::SEARCH_PANE)->hasEntry('Ready to search');
|
||||||
|
|
||||||
$this->assertTrue($result, 'Dashboard::search() could not get hint for search');
|
$this->assertTrue($result, 'SearchDashboard::search() could not get hint for search');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user