diff --git a/library/Icinga/Application/Modules/DashletManager.php b/library/Icinga/Application/Modules/DashletManager.php index 8f6e7740a..dd9cdb3c9 100644 --- a/library/Icinga/Application/Modules/DashletManager.php +++ b/library/Icinga/Application/Modules/DashletManager.php @@ -43,7 +43,7 @@ class DashletManager { $query = Model\ModuleDashlet::on(DBUtils::getConn()) ->disableDefaultSort() - ->setColumns([new Expression('1')]) + ->columns([new Expression('1')]) ->filter(Filter::equal('id', $dashlet->getUuid())); return $query->execute()->hasResult(); diff --git a/library/Icinga/Web/Dashboard/Common/DashboardUserManager.php b/library/Icinga/Web/Dashboard/Common/DashboardUserManager.php index 3c3ef4d52..519d4358e 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardUserManager.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardUserManager.php @@ -71,7 +71,7 @@ trait DashboardUserManager public static function userExist(): bool { $query = DashboardOwner::on(DBUtils::getConn()) - ->setColumns(['id']) + ->columns(['id']) ->filter(Filter::equal('username', self::getUser()->getUsername())); $found = false; diff --git a/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php b/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php index 32b31f53e..5514ed816 100644 --- a/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php +++ b/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php @@ -4,12 +4,11 @@ namespace Tests\Icinga\Web; use Icinga\Application\Icinga; -use Icinga\Authentication\Role; -use Icinga\Test\BaseTestCase; -use Icinga\User; +use Icinga\Exception\Http\HttpNotFoundException; +use Icinga\Test\BaseDashboardTestCase; use Icinga\Web\Widget\SearchDashboard; -class SearchDashboardTest extends BaseTestCase +class SearchDashboardTest extends BaseDashboardTestCase { public function setUp(): void { @@ -23,48 +22,38 @@ class SearchDashboardTest extends BaseTestCase 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->setUser($user); - $dashboard = $dashboard->search('pending'); - $dashboard->getPane('search')->removeDashlets(); + $dashboard->setUser($this->getUser()); + $dashboard->search('pending'); + + $searchHome = $dashboard->getActiveHome(); + $searchHome->getEntry(SearchDashboard::SEARCH_PANE)->setEntries([]); $dashboard->render(); } public function testWhetherSearchLoadsSearchDashletsFromModules() { - $role = new Role(); - $role->setPermissions(['*']); - - $user = new User('test'); - $user->setRoles([$role]); - $dashboard = new SearchDashboard(); - $dashboard->setUser($user); - $dashboard = $dashboard->search('pending'); + $dashboard->setUser($this->getUser()); + $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() { - $role = new Role(); - $role->setPermissions(['*']); - - $user = new User('test'); - $user->setRoles([$role]); - $dashboard = new SearchDashboard(); - $dashboard->setUser($user); - $dashboard = $dashboard->search(); + $dashboard->setUser($this->getUser()); + $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'); } }