mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Merge branch 'bugfix/pagination-fixes-4589'
fixes #4589 fixes #4591 fixes #4572
This commit is contained in:
commit
30e36f1e09
@ -43,7 +43,7 @@ class AuthenticationController extends ActionController
|
|||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $handlesAuthentication = true;
|
protected $requiresAuthentication = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controller modifies the session
|
* This controller modifies the session
|
||||||
|
@ -38,12 +38,11 @@ use \Icinga\Application\Icinga;
|
|||||||
class IndexController extends ActionController
|
class IndexController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Always authenticate
|
* Use a default redirection rule to welcome page
|
||||||
*/
|
*/
|
||||||
public function preDispatch()
|
public function preDispatch()
|
||||||
{
|
{
|
||||||
parent::preDispatch(); // -> auth :(
|
if ($this->getRequest()->getActionName() !== 'welcome') {
|
||||||
if ($this->action_name !== 'welcome') {
|
|
||||||
$this->redirect('index/welcome');
|
$this->redirect('index/welcome');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,42 +35,24 @@ use \Icinga\Application\Logger;
|
|||||||
class StaticController extends ActionController
|
class StaticController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @TODO: Bug #4572
|
* Static routes don't require authentication
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $handlesAuthentication = true;
|
protected $requiresAuthentication = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable layout rendering as this controller doesn't provide any html layouts
|
||||||
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
$this->_helper->layout()->disableLayout();
|
$this->_helper->layout()->disableLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getModuleList()
|
/**
|
||||||
{
|
* Return an image from the application's or the module's public folder
|
||||||
$modules = Icinga::app()->getModuleManager()->getLoadedModules();
|
*/
|
||||||
// preliminary static definition
|
|
||||||
$result = array();
|
|
||||||
foreach ($modules as $name => $module) {
|
|
||||||
$hasJs = file_exists($module->getBasedir() . '/public/js/' . $name . '.js');
|
|
||||||
$result[] = array(
|
|
||||||
'name' => $name,
|
|
||||||
'active' => true,
|
|
||||||
'type' => 'generic',
|
|
||||||
'behaviour' => $hasJs
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function modulelistAction()
|
|
||||||
{
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
$this->_helper->layout()->disableLayout();
|
|
||||||
$this->getResponse()->setHeader('Content-Type', 'application/json');
|
|
||||||
echo 'define(function() { return ' . json_encode($this->getModuleList(), true) . '; })';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function imgAction()
|
public function imgAction()
|
||||||
{
|
{
|
||||||
$module = $this->_getParam('module_name');
|
$module = $this->_getParam('module_name');
|
||||||
@ -107,6 +89,9 @@ class StaticController extends ActionController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a javascript file from the application's or the module's public folder
|
||||||
|
*/
|
||||||
public function javascriptAction()
|
public function javascriptAction()
|
||||||
{
|
{
|
||||||
$module = $this->_getParam('module_name');
|
$module = $this->_getParam('module_name');
|
||||||
|
@ -61,12 +61,6 @@ class Query extends AbstractQuery
|
|||||||
protected function createQueryObjects()
|
protected function createQueryObjects()
|
||||||
{
|
{
|
||||||
$this->beforeCreatingCountQuery();
|
$this->beforeCreatingCountQuery();
|
||||||
$this->countQuery = clone($this->baseQuery);
|
|
||||||
if ($this->countColumns === null) {
|
|
||||||
$this->countColumns = array('cnt' => 'COUNT(*)');
|
|
||||||
}
|
|
||||||
$this->countQuery->columns($this->countColumns);
|
|
||||||
|
|
||||||
$this->beforeCreatingSelectQuery();
|
$this->beforeCreatingSelectQuery();
|
||||||
$this->selectQuery = clone($this->baseQuery);
|
$this->selectQuery = clone($this->baseQuery);
|
||||||
$this->selectQuery->columns($this->columns);
|
$this->selectQuery->columns($this->columns);
|
||||||
@ -79,6 +73,12 @@ class Query extends AbstractQuery
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->countQuery = clone($this->baseQuery);
|
||||||
|
if ($this->countColumns === null) {
|
||||||
|
$this->countColumns = array('cnt' => 'COUNT(*)');
|
||||||
|
}
|
||||||
|
$this->countQuery->columns($this->countColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function beforeCreatingCountQuery()
|
protected function beforeCreatingCountQuery()
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
use \Zend_Controller_Action as ZfController;
|
use \Zend_Controller_Action;
|
||||||
use \Zend_Controller_Request_Abstract as ZfRequest;
|
use \Zend_Controller_Request_Abstract;
|
||||||
use \Zend_Controller_Response_Abstract as ZfResponse;
|
use \Zend_Controller_Response_Abstract;
|
||||||
use \Zend_Controller_Action_HelperBroker as ZfActionHelper;
|
use \Zend_Controller_Action_HelperBroker;
|
||||||
use \Zend_Layout as ZfLayout;
|
use \Zend_Layout;
|
||||||
use \Icinga\Authentication\Manager as AuthManager;
|
use \Icinga\Authentication\Manager as AuthManager;
|
||||||
use \Icinga\Application\Benchmark;
|
use \Icinga\Application\Benchmark;
|
||||||
use \Icinga\Exception;
|
use \Icinga\Exception;
|
||||||
@ -46,7 +46,7 @@ use \Icinga\Web\Url;
|
|||||||
*
|
*
|
||||||
* All Icinga Web core controllers should extend this class
|
* All Icinga Web core controllers should extend this class
|
||||||
*/
|
*/
|
||||||
class ActionController extends ZfController
|
class ActionController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* True to mark this layout to not render the full layout
|
* True to mark this layout to not render the full layout
|
||||||
@ -56,12 +56,11 @@ class ActionController extends ZfController
|
|||||||
protected $replaceLayout = false;
|
protected $replaceLayout = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, this controller will be shown even when no authentication is available
|
* Whether the controller requires the user to be authenticated
|
||||||
* Needed mainly for the authentication controller
|
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $handlesAuthentication = false;
|
protected $requiresAuthentication = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set true when this controller modifies the session
|
* Set true when this controller modifies the session
|
||||||
@ -74,74 +73,57 @@ class ActionController extends ZfController
|
|||||||
*/
|
*/
|
||||||
protected $modifiesSession = false;
|
protected $modifiesSession = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* True if authentication succeeded, otherwise false
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $allowAccess = false;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current module name. TODO: Find out whether this shall be null for
|
|
||||||
* non-module actions
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $module_name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current controller name
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $controller_name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current action name
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $action_name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor starts benchmarking, loads the configuration and sets
|
* The constructor starts benchmarking, loads the configuration and sets
|
||||||
* other useful controller properties
|
* other useful controller properties
|
||||||
*
|
*
|
||||||
* @param ZfRequest $request
|
* @param Zend_Controller_Request_Abstract $request
|
||||||
* @param ZfResponse $response
|
* @param Zend_Controller_Response_Abstract $response
|
||||||
* @param array $invokeArgs Any additional invocation arguments
|
* @param array $invokeArgs Any additional invocation arguments
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ZfRequest $request,
|
Zend_Controller_Request_Abstract $request,
|
||||||
ZfResponse $response,
|
Zend_Controller_Response_Abstract $response,
|
||||||
array $invokeArgs = array()
|
array $invokeArgs = array()
|
||||||
) {
|
) {
|
||||||
Benchmark::measure('Action::__construct()');
|
|
||||||
|
|
||||||
$this->module_name = $request->getModuleName();
|
|
||||||
$this->controller_name = $request->getControllerName();
|
|
||||||
$this->action_name = $request->getActionName();
|
|
||||||
|
|
||||||
$this->setRequest($request)
|
$this->setRequest($request)
|
||||||
->setResponse($response)
|
->setResponse($response)
|
||||||
->_setInvokeArgs($invokeArgs);
|
->_setInvokeArgs($invokeArgs);
|
||||||
$this->_helper = new ZfActionHelper($this);
|
$this->_helper = new Zend_Controller_Action_HelperBroker($this);
|
||||||
|
|
||||||
if ($this->handlesAuthentication ||
|
// when noInit is set (e.g. for testing), authentication and init is skipped
|
||||||
AuthManager::getInstance(
|
if (isset($invokeArgs['noInit'])) {
|
||||||
null,
|
return;
|
||||||
array(
|
}
|
||||||
'writeSession' => $this->modifiesSession
|
|
||||||
)
|
if ($this->requiresLogin() === false) {
|
||||||
)->isAuthenticated()
|
|
||||||
) {
|
|
||||||
$this->allowAccess = true;
|
|
||||||
$this->view->tabs = new Tabs();
|
$this->view->tabs = new Tabs();
|
||||||
$this->init();
|
$this->init();
|
||||||
|
} else {
|
||||||
|
$this->redirectToLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the controller requires a login. That is when the controller requires authentication and the
|
||||||
|
* user is currently not authenticated
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* @see requiresAuthentication
|
||||||
|
*/
|
||||||
|
protected function requiresLogin()
|
||||||
|
{
|
||||||
|
if (!$this->requiresAuthentication) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return !AuthManager::getInstance(
|
||||||
|
null,
|
||||||
|
array('writeSession' => $this->modifiesSession)
|
||||||
|
)->isAuthenticated();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tabs
|
* Return the tabs
|
||||||
*
|
*
|
||||||
@ -165,36 +147,13 @@ class ActionController extends ZfController
|
|||||||
return t($string);
|
return t($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect to the login path
|
||||||
|
*/
|
||||||
private function redirectToLogin()
|
private function redirectToLogin()
|
||||||
{
|
{
|
||||||
$this->_request->setModuleName('default')
|
$url = Url::fromPath('/authentication/login');
|
||||||
->setControllerName('authentication')
|
$this->redirectNow($url->getRelativeUrl());
|
||||||
->setActionName('login')
|
|
||||||
->setDispatched(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare action execution by testing for correct permissions and setting shortcuts
|
|
||||||
*/
|
|
||||||
public function preDispatch()
|
|
||||||
{
|
|
||||||
Benchmark::measure('Action::preDispatch()');
|
|
||||||
if (! $this->allowAccess) {
|
|
||||||
return $this->redirectToLogin();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->view->action_name = $this->action_name;
|
|
||||||
$this->view->controller_name = $this->controller_name;
|
|
||||||
$this->view->module_name = $this->module_name;
|
|
||||||
|
|
||||||
Benchmark::measure(
|
|
||||||
sprintf(
|
|
||||||
'Action::preDispatched(): %s / %s / %s',
|
|
||||||
$this->module_name,
|
|
||||||
$this->controller_name,
|
|
||||||
$this->action_name
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
/**
|
|
||||||
* This file is part of Icinga 2 Web.
|
|
||||||
*
|
|
||||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
|
||||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
|
||||||
*/
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module action controller
|
|
||||||
*/
|
|
||||||
namespace Icinga\Web\Controller;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class for all module action controllers
|
|
||||||
*
|
|
||||||
* @TODO: Only here for compatibility and testing reasons, make ActionController testable and remove this (Bug #4540)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class ModuleActionController extends ActionController
|
|
||||||
{
|
|
||||||
}
|
|
@ -32,7 +32,7 @@ use \Monitoring\Backend;
|
|||||||
use \Icinga\Application\Config;
|
use \Icinga\Application\Config;
|
||||||
use \Icinga\Application\Logger;
|
use \Icinga\Application\Logger;
|
||||||
use \Icinga\Web\Form;
|
use \Icinga\Web\Form;
|
||||||
use \Icinga\Web\Controller\ModuleActionController;
|
use \Icinga\Web\Controller\ActionController;
|
||||||
use \Icinga\Protocol\Commandpipe\CommandPipe;
|
use \Icinga\Protocol\Commandpipe\CommandPipe;
|
||||||
use \Icinga\Exception\ConfigurationError;
|
use \Icinga\Exception\ConfigurationError;
|
||||||
use \Icinga\Exception\MissingParameterException;
|
use \Icinga\Exception\MissingParameterException;
|
||||||
@ -51,7 +51,7 @@ use \Monitoring\Form\Command\SubmitPassiveCheckResultForm;
|
|||||||
*
|
*
|
||||||
* Interface to send commands and display forms
|
* Interface to send commands and display forms
|
||||||
*/
|
*/
|
||||||
class Monitoring_CommandController extends ModuleActionController
|
class Monitoring_CommandController extends ActionController
|
||||||
{
|
{
|
||||||
const DEFAULT_VIEW_SCRIPT = 'renderform';
|
const DEFAULT_VIEW_SCRIPT = 'renderform';
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
use \Icinga\Application\Benchmark;
|
use \Icinga\Application\Benchmark;
|
||||||
use \Icinga\Data\Db\Query;
|
use \Icinga\Data\Db\Query;
|
||||||
use \Icinga\File\Csv;
|
use \Icinga\File\Csv;
|
||||||
use \Icinga\Web\Controller\ModuleActionController;
|
use \Icinga\Web\Controller\ActionController;
|
||||||
use \Icinga\Web\Hook;
|
use \Icinga\Web\Hook;
|
||||||
use \Icinga\Web\Widget\Tabextension\BasketAction;
|
use \Icinga\Web\Widget\Tabextension\BasketAction;
|
||||||
use \Icinga\Web\Widget\Tabextension\DashboardAction;
|
use \Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
@ -39,7 +39,7 @@ use \Icinga\Web\Widget\Tabextension\OutputFormat;
|
|||||||
use \Icinga\Web\Widget\Tabs;
|
use \Icinga\Web\Widget\Tabs;
|
||||||
use \Monitoring\Backend;
|
use \Monitoring\Backend;
|
||||||
|
|
||||||
class Monitoring_ListController extends ModuleActionController
|
class Monitoring_ListController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The backend used for this controller
|
* The backend used for this controller
|
||||||
@ -68,6 +68,16 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
$this->createTabs();
|
$this->createTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrite the backend to use (used for testing)
|
||||||
|
*
|
||||||
|
* @param Backend $backend The Backend that should be used for querying
|
||||||
|
*/
|
||||||
|
public function setBackend($backend)
|
||||||
|
{
|
||||||
|
$this->backend = $backend;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display host list
|
* Display host list
|
||||||
*/
|
*/
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
use Monitoring\Backend;
|
use Monitoring\Backend;
|
||||||
use Icinga\Web\Controller\ModuleActionController;
|
use Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
use Monitoring\Object\Host;
|
use Monitoring\Object\Host;
|
||||||
use Monitoring\Object\Service;
|
use Monitoring\Object\Service;
|
||||||
@ -43,7 +43,7 @@ use Icinga\Web\Widget\Tabextension\BasketAction;
|
|||||||
*
|
*
|
||||||
* Actions for show context
|
* Actions for show context
|
||||||
*/
|
*/
|
||||||
class Monitoring_ShowController extends ModuleActionController
|
class Monitoring_ShowController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Backend
|
* @var Backend
|
||||||
|
@ -26,96 +26,26 @@
|
|||||||
*/
|
*/
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
namespace Icinga\Web\Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Mocked controller base class to avoid the complete
|
|
||||||
* Bootstrap dependency of the normally used ModuleActionController
|
|
||||||
*/
|
|
||||||
class ModuleActionController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The view this controller would create
|
|
||||||
* @var stdClass
|
|
||||||
*/
|
|
||||||
public $view;
|
|
||||||
|
|
||||||
public $headers = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parameters provided on call
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $params = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* _getParam method that normally retrieves GET/POST parameters
|
|
||||||
*
|
|
||||||
* @param string $param The parameter name to retrieve
|
|
||||||
* @return mixed|bool The parameter $param or false if it doesn't exist
|
|
||||||
*/
|
|
||||||
public function _getParam($param, $default = null)
|
|
||||||
{
|
|
||||||
if (!isset($this->params[$param])) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $this->params[$param];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getParam($param, $default = null)
|
|
||||||
{
|
|
||||||
return $this->_getParam($param, $default);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function preserve()
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getParams()
|
|
||||||
{
|
|
||||||
return $this->params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the backend for this controller which will be used in the action
|
|
||||||
*
|
|
||||||
* @param $backend
|
|
||||||
*/
|
|
||||||
public function setBackend($backend)
|
|
||||||
{
|
|
||||||
$this->backend = $backend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __get($param) {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHeader($header) {
|
|
||||||
if (isset($this->headers[$header])) {
|
|
||||||
return $this->headers[$header];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace Test\Monitoring\Testlib
|
|
||||||
{
|
|
||||||
require_once 'Zend/View.php';
|
|
||||||
|
|
||||||
use \Zend_View;
|
namespace Test\Monitoring\Testlib;
|
||||||
use \Zend_Config;
|
|
||||||
use \Icinga\Protocol\Statusdat\Reader;
|
|
||||||
use \Icinga\Web\Controller\ActionController;
|
|
||||||
use \Icinga\Application\DbAdapterFactory;
|
|
||||||
use \Monitoring\Backend\Ido;
|
|
||||||
use \Monitoring\Backend\Statusdat;
|
|
||||||
use \Test\Monitoring\Testlib\DataSource\TestFixture;
|
|
||||||
use \Test\Monitoring\Testlib\DataSource\DataSourceTestSetup;
|
|
||||||
|
|
||||||
/**
|
require_once 'Zend/View.php';
|
||||||
|
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
|
||||||
|
|
||||||
|
use \Zend_View;
|
||||||
|
use \Zend_Config;
|
||||||
|
use \Zend_Test_PHPUnit_ControllerTestCase;
|
||||||
|
use \Icinga\Protocol\Statusdat\Reader;
|
||||||
|
use \Icinga\Web\Controller\ActionController;
|
||||||
|
use \Icinga\Application\DbAdapterFactory;
|
||||||
|
use \Monitoring\Backend\Ido;
|
||||||
|
use \Monitoring\Backend\Statusdat;
|
||||||
|
use \Test\Monitoring\Testlib\DataSource\TestFixture;
|
||||||
|
use \Test\Monitoring\Testlib\DataSource\DataSourceTestSetup;
|
||||||
|
|
||||||
|
/**
|
||||||
* Base class for monitoring controllers that loads required dependencies
|
* Base class for monitoring controllers that loads required dependencies
|
||||||
* and allows easier setup of tests
|
* and allows easier setup of tests
|
||||||
*
|
*
|
||||||
@ -139,8 +69,8 @@ namespace Test\Monitoring\Testlib
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
abstract class MonitoringControllerTest extends \PHPUnit_Framework_TestCase
|
abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The module directory for requiring modules (is relative to the source file)
|
* The module directory for requiring modules (is relative to the source file)
|
||||||
* @var string
|
* @var string
|
||||||
@ -260,7 +190,11 @@ namespace Test\Monitoring\Testlib
|
|||||||
require_once($this->moduleDir.'/application/controllers/'.$controller.'.php');
|
require_once($this->moduleDir.'/application/controllers/'.$controller.'.php');
|
||||||
$controllerName = '\Monitoring_'.ucfirst($controller);
|
$controllerName = '\Monitoring_'.ucfirst($controller);
|
||||||
/** @var ActionController $controller */
|
/** @var ActionController $controller */
|
||||||
$controller = new $controllerName;
|
$controller = new $controllerName(
|
||||||
|
$this->getRequest(),
|
||||||
|
$this->getResponse(),
|
||||||
|
array('noInit' => true)
|
||||||
|
);
|
||||||
$controller->setBackend($this->getBackendFor($backend));
|
$controller->setBackend($this->getBackendFor($backend));
|
||||||
|
|
||||||
// Many controllers need a view to work properly
|
// Many controllers need a view to work properly
|
||||||
@ -328,5 +262,4 @@ namespace Test\Monitoring\Testlib
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user