Skip to content

Commit

Permalink
SearchDashboard: rename ::load() to ::search()
Browse files Browse the repository at this point in the history
Function signature didn't match parent factory function

fixes #7081
  • Loading branch information
Thomas-Gelf committed Sep 4, 2014
1 parent 0f8d5bd commit 0f7f2f2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion application/controllers/SearchController.php
Expand Up @@ -13,7 +13,7 @@ class SearchController extends ActionController
{
public function indexAction()
{
$this->view->dashboard = SearchDashboard::load($this->params->get('q'));
$this->view->dashboard = SearchDashboard::search($this->params->get('q'));

// NOTE: This renders the dashboard twice. Remove this once we can catch exceptions thrown in view scripts.
$this->view->dashboard->render();
Expand Down
2 changes: 1 addition & 1 deletion application/layouts/scripts/parts/navigation.phtml
Expand Up @@ -12,7 +12,7 @@ if (! $this->auth()->isAuthenticated()) {

?>
<div id="menu" data-base-target="_main">
<? if (SearchDashboard::load('dummy')->getPane('search')->hasComponents()): ?>
<? if (SearchDashboard::search('dummy')->getPane('search')->hasComponents()): ?>
<form action="<?= $this->href('search') ?>" method="get" role="search">
<input type="text" name="q" class="search autofocus" placeholder="<?= $this->translate('Search...') ?>" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
</form>
Expand Down
2 changes: 1 addition & 1 deletion library/Icinga/Web/Widget/SearchDashboard.php
Expand Up @@ -32,7 +32,7 @@ class SearchDashboard extends Dashboard
* @param $searchQuery
* @return Dashboard|SearchDashboard
*/
public static function load($searchQuery = '')
public static function search($searchQuery = '')
{
/** @var $dashboard SearchDashboard */
$dashboard = new static('searchDashboard');
Expand Down
10 changes: 5 additions & 5 deletions test/php/library/Icinga/Web/Widget/SearchDashboardTest.php
Expand Up @@ -48,27 +48,27 @@ function () use ($request) { return $request; }
*/
public function testFoo()
{
$dashboard = SearchDashboard::load('pending');
$dashboard = SearchDashboard::search('pending');
$dashboard->getPane('search')->removeComponents();
$dashboard->render();
}

public function testWhetherLoadLoadsSearchDashletsFromModules()
{
$dashboard = SearchDashboard::load('pending');
$dashboard = SearchDashboard::search('pending');

$result = $dashboard->getPane('search')->hasComponent('Hosts: pending');

$this->assertTrue($result, 'Dashboard::load() could not load search dashlets from modules');
$this->assertTrue($result, 'Dashboard::search() could not load search dashlets from modules');
}


public function testWhetherLoadProvidesHint()
{
$dashboard = SearchDashboard::load('');
$dashboard = SearchDashboard::search('');

$result = $dashboard->getPane('search')->hasComponent('Ready to search');

$this->assertTrue($result, 'Dashboard::load() could not get hint for search');
$this->assertTrue($result, 'Dashboard::search() could not get hint for search');
}
}

0 comments on commit 0f7f2f2

Please sign in to comment.