mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 07:14:35 +02:00
Refactor test, tabs and controller
- Remove unused methods, - Code style - Documentation for widgets - Tabextensions instead of hardcoded tab actions - Add tests for tabs - Add missing phpdoc for touched files - Fix tests refs #4512 refs #4541 refs #4540
This commit is contained in:
parent
346ab198bb
commit
b28c7f2f4c
@ -34,7 +34,6 @@ use Icinga\Application\Icinga;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IndexController
|
* Class IndexController
|
||||||
* @package Icinga\Application\Controllers
|
|
||||||
*/
|
*/
|
||||||
class IndexController extends ActionController
|
class IndexController extends ActionController
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,30 @@
|
|||||||
<?php
|
<?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}}}
|
||||||
|
|
||||||
namespace Icinga\Form\Dashboard;
|
namespace Icinga\Form\Dashboard;
|
||||||
|
|
||||||
@ -103,6 +129,7 @@ class AddUrlForm extends Form
|
|||||||
protected function create()
|
protected function create()
|
||||||
{
|
{
|
||||||
$dashboard = new Dashboard();
|
$dashboard = new Dashboard();
|
||||||
|
|
||||||
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
|
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
@ -110,6 +137,7 @@ class AddUrlForm extends Form
|
|||||||
array(
|
array(
|
||||||
'label' => 'Url',
|
'label' => 'Url',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'value' => $this->getRequest()->getParam('url', null)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$elems = $dashboard->getPaneKeyTitleArray();
|
$elems = $dashboard->getPaneKeyTitleArray();
|
||||||
@ -132,5 +160,6 @@ class AddUrlForm extends Form
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->setSubmitLabel("Add to dashboard");
|
$this->setSubmitLabel("Add to dashboard");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
97
doc/widgets.md
Normal file
97
doc/widgets.md
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
# Widgets
|
||||||
|
|
||||||
|
Widgets are reusable UI components that are able to render themselves and return HTML to be included in your template.
|
||||||
|
|
||||||
|
## Basic interface
|
||||||
|
|
||||||
|
The interface needed for implementing widgets can be found under library/Icinga/Web/Widget/Widget.php. This is a rather
|
||||||
|
simple interface, only providing a 'render' method that takes a view and returns HTML:
|
||||||
|
|
||||||
|
interface Widget
|
||||||
|
{
|
||||||
|
public function render(Zend_View_Abstract $view);
|
||||||
|
}
|
||||||
|
|
||||||
|
When implementing own Widgets you just have to make sure that your provide this render method.
|
||||||
|
|
||||||
|
## Using widgets
|
||||||
|
|
||||||
|
Widgets are normally created in the controller and added to the view:
|
||||||
|
|
||||||
|
// in your Controller
|
||||||
|
public function myControllerAction()
|
||||||
|
{
|
||||||
|
$this->view->myWidget = new MyWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
The HTML is then rendered in the template using the *render()* method described above. As the '$this' scope in a view is your
|
||||||
|
a reference to your current view, you can just pass it to the *render()* method:
|
||||||
|
|
||||||
|
// in your template
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h4>Look at my beautiful widget</h4>
|
||||||
|
<?= $this->myWidget->render($this); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## The 'Tabs' widget
|
||||||
|
|
||||||
|
The Tabs (Icinga\Web\Widgets\Tabs) widget handles creation of Tab bars and allows you to create and add single tabs to this view. To create an empty
|
||||||
|
Tab bar, you just have to call:
|
||||||
|
|
||||||
|
$tabbar = new Tabs();
|
||||||
|
|
||||||
|
**Note** : When using an ActionController, there's already an empty tabs object created unter $this->view->tabs. This is
|
||||||
|
done in the preDispatch function
|
||||||
|
|
||||||
|
### Adding tabs
|
||||||
|
|
||||||
|
Afterwards you can add tabs by calling the add($name, $tab) function, whereas $name is the name of your tab and $tab
|
||||||
|
is either an array with tab parameters or an existing Tab object.
|
||||||
|
|
||||||
|
// Adding tabs:
|
||||||
|
$tabbar->add("myTab", array(
|
||||||
|
"title" => "My hosts", // displayed as the tab text
|
||||||
|
"iconCls" => "myicon", // icon-myicon will be used as an icon in a <i> tag
|
||||||
|
"url" => "/my/url", // the url to use
|
||||||
|
"urlParams" => array("host" => "localhost") // will be used as GET parameter
|
||||||
|
));
|
||||||
|
|
||||||
|
### Adding tabs to the dropdown list
|
||||||
|
|
||||||
|
Sometimes you want additional actions to be displayed in your tabbar. This can be accomplished with the 'addAsDropdown'
|
||||||
|
method. This one is similar to the *add* method, but displays your tab in a dropdown list on the right side of the tabbar.
|
||||||
|
|
||||||
|
## Using tabextensions
|
||||||
|
|
||||||
|
Often you find yourself adding the same tabs over and over again. You can write a Tabextension that does this for you
|
||||||
|
and just apply them on your tabs. Tabextensions are locate the Icinga/Web/Widgets/Tabextension/ and use the simple
|
||||||
|
Tabextension interface that just defines *apply(Tabs $tab)*. A simple example is the DashboardAction Tabextender which
|
||||||
|
just adds a new field to the dropdown list:
|
||||||
|
|
||||||
|
class DashboardAction implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @see Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
$tabs->addAsDropdown(
|
||||||
|
'dashboard',
|
||||||
|
array(
|
||||||
|
'title' => 'Add to Dashboard',
|
||||||
|
'iconCls' => 'dashboard',
|
||||||
|
'url' => Url::fromPath('dashboard/addurl'),
|
||||||
|
'urlParams' => array(
|
||||||
|
'url' => Url::fromRequest()->getRelativeUrl()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
You can now either extend your Tabs object using the DashboardAction's *apply()* method or by calling the Tabs *extend*
|
||||||
|
method (which is more fluent):
|
||||||
|
|
||||||
|
$tabs->extend(new DashboardAction())
|
||||||
|
|
@ -32,17 +32,13 @@ use \Icinga\Application\Benchmark;
|
|||||||
use \Icinga\Exception;
|
use \Icinga\Exception;
|
||||||
use \Icinga\Application\Config;
|
use \Icinga\Application\Config;
|
||||||
use \Icinga\Web\Notification;
|
use \Icinga\Web\Notification;
|
||||||
|
use \Icinga\Web\Widget\Tabs;
|
||||||
use \Zend_Layout as ZfLayout;
|
use \Zend_Layout as ZfLayout;
|
||||||
use \Zend_Controller_Action as ZfController;
|
use \Zend_Controller_Action as ZfController;
|
||||||
use \Zend_Controller_Request_Abstract as ZfRequest;
|
use \Zend_Controller_Request_Abstract as ZfRequest;
|
||||||
use \Zend_Controller_Response_Abstract as ZfResponse;
|
use \Zend_Controller_Response_Abstract as ZfResponse;
|
||||||
use \Zend_Controller_Action_HelperBroker as ZfActionHelper;
|
use \Zend_Controller_Action_HelperBroker as ZfActionHelper;
|
||||||
|
|
||||||
/*
|
|
||||||
* @TODO(el): There was a note from tg that the following line is temporary. Ask him why.
|
|
||||||
*/
|
|
||||||
use Icinga\File\Pdf;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all core action controllers
|
* Base class for all core action controllers
|
||||||
*
|
*
|
||||||
@ -54,15 +50,41 @@ use Icinga\File\Pdf;
|
|||||||
*/
|
*/
|
||||||
class ActionController extends ZfController
|
class ActionController extends ZfController
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The Icinga Config object is available in all controllers. This is the
|
|
||||||
* modules config for module action controllers.
|
|
||||||
* @var Config
|
|
||||||
*/
|
|
||||||
protected $config;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True to mark this layout to not render the full layout
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
protected $replaceLayout = false;
|
protected $replaceLayout = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, this controller will be shown even when no authentication is available
|
||||||
|
* Needed mainly for the authentication controller
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $handlesAuthentication = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set true when this controller modifies the session.
|
||||||
|
*
|
||||||
|
* otherwise the session will be written back to disk and closed before the controller
|
||||||
|
* action is executed, leading to every modification in the session to be lost after
|
||||||
|
* the response is submitted
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $modifiesSession = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if authentication suceeded, otherwise false
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
**/
|
||||||
|
protected $allowAccess = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current module name. TODO: Find out whether this shall be null for
|
* The current module name. TODO: Find out whether this shall be null for
|
||||||
* non-module actions
|
* non-module actions
|
||||||
@ -85,12 +107,7 @@ class ActionController extends ZfController
|
|||||||
*/
|
*/
|
||||||
protected $action_name;
|
protected $action_name;
|
||||||
|
|
||||||
// @TODO(el): Should be true, is/was disabled for testing purpose
|
|
||||||
protected $handlesAuthentication = false;
|
|
||||||
|
|
||||||
protected $modifiesSession = false;
|
|
||||||
|
|
||||||
private $allowAccess = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor starts benchmarking, loads the configuration and sets
|
* The constructor starts benchmarking, loads the configuration and sets
|
||||||
@ -111,13 +128,12 @@ class ActionController extends ZfController
|
|||||||
$this->controller_name = $request->getControllerName();
|
$this->controller_name = $request->getControllerName();
|
||||||
$this->action_name = $request->getActionName();
|
$this->action_name = $request->getActionName();
|
||||||
|
|
||||||
$this->loadConfig();
|
|
||||||
$this->setRequest($request)
|
$this->setRequest($request)
|
||||||
->setResponse($response)
|
->setResponse($response)
|
||||||
->_setInvokeArgs($invokeArgs);
|
->_setInvokeArgs($invokeArgs);
|
||||||
$this->_helper = new ZfActionHelper($this);
|
$this->_helper = new ZfActionHelper($this);
|
||||||
|
|
||||||
if ($this->handlesAuthentication() ||
|
if ($this->handlesAuthentication ||
|
||||||
AuthManager::getInstance(
|
AuthManager::getInstance(
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
@ -126,24 +142,26 @@ class ActionController extends ZfController
|
|||||||
)->isAuthenticated()
|
)->isAuthenticated()
|
||||||
) {
|
) {
|
||||||
$this->allowAccess = true;
|
$this->allowAccess = true;
|
||||||
|
$this->view->tabs = new Tabs();
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is where the configuration is going to be loaded
|
* Return the @see \Icinga\Widget\Web\Tabs of this view
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Tabs
|
||||||
*/
|
**/
|
||||||
protected function loadConfig()
|
public function getTabs()
|
||||||
{
|
{
|
||||||
$this->config = Config::app();
|
return $this->view->tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the given string with the global translation catalog
|
* Translate the given string with the global translation catalog
|
||||||
*
|
*
|
||||||
* @param string $string The string that should be translated
|
* @param string $string The string that should be translated
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -155,14 +173,11 @@ class ActionController extends ZfController
|
|||||||
/**
|
/**
|
||||||
* Whether the current user has the given permission
|
* Whether the current user has the given permission
|
||||||
*
|
*
|
||||||
* TODO: This has not been implemented yet
|
* TODO: This has not been implemented yet (Feature #4111)
|
||||||
*
|
|
||||||
* @param string $permission Permission name
|
|
||||||
* @param string $object No idea what this should have been :-)
|
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
final protected function hasPermission($uri, $permission = 'read')
|
final protected function hasPermission($uri)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -170,38 +185,25 @@ class ActionController extends ZfController
|
|||||||
/**
|
/**
|
||||||
* Assert the current user has the given permission
|
* Assert the current user has the given permission
|
||||||
*
|
*
|
||||||
* TODO: This has not been implemented yet
|
* TODO: This has not been implemented yet (Feature #4111)
|
||||||
*
|
*
|
||||||
* @param string $permission Permission name
|
|
||||||
* @param string $object No idea what this should have been :-)
|
|
||||||
*
|
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
final protected function assertPermission($permission, $object = null)
|
final protected function assertPermission()
|
||||||
{
|
{
|
||||||
if (! $this->hasPermission($permission, $object)) {
|
|
||||||
// TODO: Log violation, create dedicated Exception class
|
|
||||||
throw new \Exception('Permission denied');
|
|
||||||
}
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function preserve($key, $value = null)
|
private function redirectToLogin()
|
||||||
{
|
{
|
||||||
if ($value === null) {
|
$this->_request->setModuleName('default')
|
||||||
$value = $this->_getParam($key);
|
->setControllerName('authentication')
|
||||||
}
|
->setActionName('login')
|
||||||
if ($value !== null) {
|
->setDispatched(false);
|
||||||
if (! isset($this->view->preserve)) {
|
|
||||||
$this->view->preserve = array();
|
|
||||||
}
|
|
||||||
$this->view->preserve[$key] = $value;
|
|
||||||
}
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our benchmark wants to know when we started our dispatch loop
|
* Prepare action execution by testing for correct permissions and setting shortcuts
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -209,20 +211,13 @@ class ActionController extends ZfController
|
|||||||
{
|
{
|
||||||
Benchmark::measure('Action::preDispatch()');
|
Benchmark::measure('Action::preDispatch()');
|
||||||
if (! $this->allowAccess) {
|
if (! $this->allowAccess) {
|
||||||
$this->_request->setModuleName('default')
|
return $this->redirectToLogin();
|
||||||
->setControllerName('authentication')
|
|
||||||
->setActionName('login')
|
|
||||||
->setDispatched(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->action_name = $this->action_name;
|
$this->view->action_name = $this->action_name;
|
||||||
$this->view->controller_name = $this->controller_name;
|
$this->view->controller_name = $this->controller_name;
|
||||||
$this->view->module_name = $this->module_name;
|
$this->view->module_name = $this->module_name;
|
||||||
|
|
||||||
// TODO(el): What is this, why do we need that here?
|
|
||||||
$this->view->compact = $this->_request->getParam('view') === 'compact';
|
|
||||||
|
|
||||||
Benchmark::measure(
|
Benchmark::measure(
|
||||||
sprintf(
|
sprintf(
|
||||||
'Action::preDispatched(): %s / %s / %s',
|
'Action::preDispatched(): %s / %s / %s',
|
||||||
@ -231,11 +226,14 @@ class ActionController extends ZfController
|
|||||||
$this->action_name
|
$this->action_name
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
//$this->quickRedirect('/authentication/login?a=e');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redirectNow($url, array $params = array())
|
/**
|
||||||
|
* Redirect to a specific url, updating the browsers URL field
|
||||||
|
*
|
||||||
|
* @param Url|string $url The target to redirect to
|
||||||
|
**/
|
||||||
|
public function redirectNow($url)
|
||||||
{
|
{
|
||||||
if ($url instanceof Url) {
|
if ($url instanceof Url) {
|
||||||
$url = $url->getRelativeUrl();
|
$url = $url->getRelativeUrl();
|
||||||
@ -243,77 +241,15 @@ class ActionController extends ZfController
|
|||||||
$this->_helper->Redirector->gotoUrlAndExit($url);
|
$this->_helper->Redirector->gotoUrlAndExit($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handlesAuthentication()
|
|
||||||
{
|
|
||||||
return $this->handlesAuthentication;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render our benchmark
|
* Detect whether the current request requires changes in the layout and apply them before rendering
|
||||||
*
|
*
|
||||||
* @return string
|
* @see Zend_Controller_Action::postDispatch()
|
||||||
*/
|
|
||||||
protected function renderBenchmark()
|
|
||||||
{
|
|
||||||
return '<pre class="benchmark">'
|
|
||||||
. Benchmark::renderToHtml()
|
|
||||||
. '</pre>';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* After dispatch happend we are going to do some automagic stuff
|
|
||||||
*
|
|
||||||
* - Benchmark is completed and rendered
|
|
||||||
* - Notifications will be collected here
|
|
||||||
* - Layout is disabled for XHR requests
|
|
||||||
* - TODO: Headers with required JS and other things will be created
|
|
||||||
* for XHR requests
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function postDispatch()
|
public function postDispatch()
|
||||||
{
|
{
|
||||||
Benchmark::measure('Action::postDispatch()');
|
Benchmark::measure('Action::postDispatch()');
|
||||||
|
|
||||||
// TODO: Move this elsewhere, this is just an ugly test:
|
|
||||||
if ($this->_request->getParam('filetype') === 'pdf') {
|
|
||||||
|
|
||||||
// Snippet stolen from less compiler in public/css.php:
|
|
||||||
|
|
||||||
require_once 'vendor/lessphp/lessc.inc.php';
|
|
||||||
$less = new \lessc;
|
|
||||||
$cssdir = dirname(ICINGA_LIBDIR) . '/public/css';
|
|
||||||
// TODO: We need a way to retrieve public dir, even if located elsewhere
|
|
||||||
|
|
||||||
$css = $less->compileFile($cssdir . '/pdfprint.less');
|
|
||||||
$this->render(
|
|
||||||
null,
|
|
||||||
$this->_helper->viewRenderer->getResponseSegment(),
|
|
||||||
$this->_helper->viewRenderer->getNoController()
|
|
||||||
);
|
|
||||||
$html = (string) $this->getResponse();
|
|
||||||
if ($this->module_name !== null) {
|
|
||||||
$html = '<div class="icinga-module module-'
|
|
||||||
. $this->module_name
|
|
||||||
. '">'
|
|
||||||
. "\n"
|
|
||||||
. $html
|
|
||||||
. '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = '<style>' . $css . '</style>' . $html;
|
|
||||||
|
|
||||||
$pdf = new Pdf();
|
|
||||||
$pdf->AddPage();
|
|
||||||
$pdf->setFontSubsetting(false);
|
|
||||||
$pdf->writeHTML($html); //0, 0, '', '', $html, 0, 1, 0, true, '', true);
|
|
||||||
|
|
||||||
$pdf->Output('docs.pdf', 'I');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
// END of PDF test
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->_request->isXmlHttpRequest()) {
|
if ($this->_request->isXmlHttpRequest()) {
|
||||||
if ($this->replaceLayout || $this->_getParam('_render') === 'body') {
|
if ($this->replaceLayout || $this->_getParam('_render') === 'body') {
|
||||||
$this->_helper->layout()->setLayout('just-the-body');
|
$this->_helper->layout()->setLayout('just-the-body');
|
||||||
@ -322,22 +258,5 @@ class ActionController extends ZfController
|
|||||||
$this->_helper->layout()->setLayout('inline');
|
$this->_helper->layout()->setLayout('inline');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$notification = Notification::getInstance();
|
|
||||||
if ($notification->hasMessages()) {
|
|
||||||
$nhtml = '<ul class="notification">';
|
|
||||||
foreach ($notification->getMessages() as $msg) {
|
|
||||||
$nhtml .= '<li>['
|
|
||||||
. $msg->type
|
|
||||||
. '] '
|
|
||||||
. htmlspecialchars($msg->message);
|
|
||||||
}
|
|
||||||
$nhtml .= '</ul>';
|
|
||||||
$this->getResponse()->append('notification', $nhtml);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AuthManager::getInstance()->getSession()->get('show_benchmark')) {
|
|
||||||
Benchmark::measure('Response ready');
|
|
||||||
$this->_helper->layout()->benchmark = $this->renderBenchmark();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
/**
|
/**
|
||||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
@ -19,7 +21,8 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @author 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}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
@ -27,84 +30,12 @@
|
|||||||
* Module action controller
|
* Module action controller
|
||||||
*/
|
*/
|
||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
use \Icinga\Application\Config as IcingaConfig;
|
|
||||||
use Icinga\Application\Icinga;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all module action controllers
|
* Base class for all module action controllers
|
||||||
*
|
*
|
||||||
* All Icinga Web module controllers should extend this class
|
* @TODO: Only here for compatibility and testing reasons, make ActionController testable and remove this (Bug #4540)
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2013 Icinga-Web Team <info@icinga.org>
|
*/
|
||||||
* @author Icinga-Web Team <info@icinga.org>
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|
||||||
*/
|
|
||||||
class ModuleActionController extends ActionController
|
class ModuleActionController extends ActionController
|
||||||
{
|
{
|
||||||
protected $module;
|
|
||||||
protected $module_dir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives you this modules base directory
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getModuleDir()
|
|
||||||
{
|
|
||||||
if ($this->module_dir === null) {
|
|
||||||
$this->module_dir = $this->getModule()->getBaseDir();
|
|
||||||
}
|
|
||||||
return $this->module_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getModule()
|
|
||||||
{
|
|
||||||
if ($this->module === null) {
|
|
||||||
$this->module = Icinga::app()->getModule(
|
|
||||||
$this->module_name
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $this->module;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates the given string with the modules translation catalog
|
|
||||||
*
|
|
||||||
* @param string $string The string that should be translated
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function translate($string)
|
|
||||||
{
|
|
||||||
return mt($this->module_name, $string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is where the module configuration is going to be loaded
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function loadConfig()
|
|
||||||
{
|
|
||||||
$this->config = IcingaConfig::module($this->module_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Once dispatched we are going to place each modules output in a div
|
|
||||||
* container having the icinga-module and the icinga-$module-name classes
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function postDispatch()
|
|
||||||
{
|
|
||||||
parent::postDispatch();
|
|
||||||
$this->_helper->layout()->moduleStart =
|
|
||||||
'<div class="icinga-module module-'
|
|
||||||
. $this->module_name
|
|
||||||
. '">'
|
|
||||||
. "\n"
|
|
||||||
;
|
|
||||||
$this->_helper->layout()->moduleEnd = "</div>\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,14 @@ use Icinga\Application\Icinga;
|
|||||||
*/
|
*/
|
||||||
class Url
|
class Url
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Rather dirty hack as the ApplicationBootstrap isn't an interface right now and can't be mocked
|
||||||
|
* overwrite this to use a specific request for all Urls (so only in tests)
|
||||||
|
*
|
||||||
|
* @var null
|
||||||
|
*/
|
||||||
|
public static $overwrittenRequest = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of all parameters stored in this Url
|
* An array of all parameters stored in this Url
|
||||||
*
|
*
|
||||||
@ -59,7 +67,7 @@ class Url
|
|||||||
public static function fromRequest(array $params = array(), $request = null)
|
public static function fromRequest(array $params = array(), $request = null)
|
||||||
{
|
{
|
||||||
if ($request === null) {
|
if ($request === null) {
|
||||||
$request = Icinga::app()->getFrontController()->getRequest();
|
$request = self::getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
$urlObject = new Url();
|
$urlObject = new Url();
|
||||||
@ -69,6 +77,19 @@ class Url
|
|||||||
return $urlObject;
|
return $urlObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a request object that should be used for determining the URL
|
||||||
|
*
|
||||||
|
* @return Zend_Abstract_Request
|
||||||
|
*/
|
||||||
|
private static function getRequest()
|
||||||
|
{
|
||||||
|
if (self::$overwrittenRequest) {
|
||||||
|
return self::$overwrittenRequest;
|
||||||
|
}
|
||||||
|
return Icinga::app()->getFrontController()->getRequest();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Url class representing the given url
|
* Create a new Url class representing the given url
|
||||||
*
|
*
|
||||||
@ -85,7 +106,7 @@ class Url
|
|||||||
{
|
{
|
||||||
$urlObject = new Url();
|
$urlObject = new Url();
|
||||||
if ($request === null) {
|
if ($request === null) {
|
||||||
$request = Icinga::app()->getFrontController()->getRequest();
|
$request = self::getRequest();
|
||||||
}
|
}
|
||||||
$urlObject->setBaseUrl($request->getBaseUrl());
|
$urlObject->setBaseUrl($request->getBaseUrl());
|
||||||
|
|
||||||
@ -174,8 +195,7 @@ class Url
|
|||||||
public function getAbsoluteUrl()
|
public function getAbsoluteUrl()
|
||||||
{
|
{
|
||||||
$url = $this->getRelativeUrl();
|
$url = $this->getRelativeUrl();
|
||||||
$baseUrl = '/'.ltrim($this->baseUrl, '/');
|
return preg_replace('/\/{2,}/', '/', '/'.$this->baseUrl.'/'.$url);
|
||||||
return $baseUrl.'/'.$url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +207,7 @@ EOD;
|
|||||||
$html = str_replace('{URL}', $url->getAbsoluteUrl(), $this->template);
|
$html = str_replace('{URL}', $url->getAbsoluteUrl(), $this->template);
|
||||||
$html = str_replace('{REMOVE_URL}', $removeUrl, $html);
|
$html = str_replace('{REMOVE_URL}', $removeUrl, $html);
|
||||||
$html = str_replace('{DIMENSION}', $this->getBoxSizeAsCSS(), $html);
|
$html = str_replace('{DIMENSION}', $this->getBoxSizeAsCSS(), $html);
|
||||||
$html = str_replace('{TITLE}', $view->escape($this->getTitle()), $html);
|
$html = str_replace('{TITLE}', htmlentities($this->getTitle()), $html);
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Icinga\Web\Url;
|
||||||
use Zend_View_Abstract;
|
use Zend_View_Abstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +100,6 @@ class Tab implements Widget
|
|||||||
*/
|
*/
|
||||||
private $iconCls = null;
|
private $iconCls = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an icon image for this tab
|
* Sets an icon image for this tab
|
||||||
*
|
*
|
||||||
@ -107,6 +107,9 @@ class Tab implements Widget
|
|||||||
*/
|
*/
|
||||||
public function setIcon($icon)
|
public function setIcon($icon)
|
||||||
{
|
{
|
||||||
|
if (is_string($icon)) {
|
||||||
|
$icon = Url::fromPath($icon);
|
||||||
|
}
|
||||||
$this->icon = $icon;
|
$this->icon = $icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,10 +155,12 @@ class Tab implements Widget
|
|||||||
*/
|
*/
|
||||||
public function setUrl($url)
|
public function setUrl($url)
|
||||||
{
|
{
|
||||||
|
if (is_string($url)) {
|
||||||
|
$url = Url::fromPath($url);
|
||||||
|
}
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the parameters to be set for this tabs Url
|
* Set the parameters to be set for this tabs Url
|
||||||
*
|
*
|
||||||
@ -181,9 +186,6 @@ class Tab implements Widget
|
|||||||
$this->$setter($value);
|
$this->$setter($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->name === null) {
|
|
||||||
throw new ProgrammingError('Cannot create a nameless tab');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,6 +205,7 @@ class Tab implements Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Widget::render()
|
* @see Widget::render()
|
||||||
*/
|
*/
|
||||||
@ -210,24 +213,16 @@ class Tab implements Widget
|
|||||||
{
|
{
|
||||||
$class = $this->active ? ' class="active"' : '';
|
$class = $this->active ? ' class="active"' : '';
|
||||||
$caption = $this->title;
|
$caption = $this->title;
|
||||||
|
|
||||||
if ($this->icon !== null) {
|
if ($this->icon !== null) {
|
||||||
$caption = $view->img(
|
$caption = '<img src="' . $this->icon->getAbsoluteUrl()
|
||||||
$this->icon,
|
. '" style="width:16px;height:16px"/> ' . $caption;
|
||||||
array(
|
|
||||||
'width' => 16,
|
|
||||||
'height' => 16
|
|
||||||
)
|
|
||||||
) . ' ' . $caption;
|
|
||||||
} elseif ($this->iconCls !== null) {
|
} elseif ($this->iconCls !== null) {
|
||||||
$caption = '<i class="icon-' . $this->iconCls . '"></i> ' . $caption;
|
$caption = '<i class="icon-' . $this->iconCls . '"></i> ' . $caption;
|
||||||
}
|
}
|
||||||
if ($this->url !== null) {
|
if ($this->url !== null) {
|
||||||
$tab = $view->qlink(
|
$this->url->addParams($this->urlParams);
|
||||||
$caption,
|
$tab = '<a href="' . $this->url->getAbsoluteUrl() . '">' . $caption . '</a>';
|
||||||
$this->url,
|
|
||||||
$this->urlParams,
|
|
||||||
array('quote' => false)
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$tab = $caption;
|
$tab = $caption;
|
||||||
}
|
}
|
||||||
|
55
library/Icinga/Web/Widget/Tabextension/BasketAction.php
Normal file
55
library/Icinga/Web/Widget/Tabextension/BasketAction.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension that adds the basket command
|
||||||
|
*
|
||||||
|
* @TODO: Baskets are not supported in the codebase yet (Feature #4537)
|
||||||
|
*/
|
||||||
|
class BasketAction implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @see Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
$tabs->addAsDropdown('basket', array(
|
||||||
|
'title' => 'URL Basket',
|
||||||
|
'icon' => 'img/classic/basket.png',
|
||||||
|
'url' => Url::fromPath('basket/add'),
|
||||||
|
'urlParams' => array(
|
||||||
|
'url' => Url::fromRequest()->getRelativeUrl()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
60
library/Icinga/Web/Widget/Tabextension/DashboardAction.php
Normal file
60
library/Icinga/Web/Widget/Tabextension/DashboardAction.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Config\Config as IcingaConfig;
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
use Icinga\Web\Widget\Dashboard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension that allows to add the current URL to a dashboard
|
||||||
|
*
|
||||||
|
* Displayed as a dropdown field in the tabs
|
||||||
|
*/
|
||||||
|
class DashboardAction implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @see Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
$tabs->addAsDropdown(
|
||||||
|
'dashboard',
|
||||||
|
array(
|
||||||
|
'title' => 'Add to Dashboard',
|
||||||
|
'iconCls' => 'dashboard',
|
||||||
|
'url' => Url::fromPath('dashboard/addurl'),
|
||||||
|
'urlParams' => array(
|
||||||
|
'url' => Url::fromRequest()->getRelativeUrl()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
128
library/Icinga/Web/Widget/Tabextension/OutputFormat.php
Normal file
128
library/Icinga/Web/Widget/Tabextension/OutputFormat.php
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use Icinga\Application\Logger;
|
||||||
|
use Icinga\Web\Widget\Tab;
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension that offers different output formats for the user in the dropdown area
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class OutputFormat implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* PDF output type
|
||||||
|
*/
|
||||||
|
const TYPE_PDF = 'pdf';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON output type
|
||||||
|
*/
|
||||||
|
const TYPE_JSON = 'json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CSV output type
|
||||||
|
*/
|
||||||
|
const TYPE_CSV = 'csv';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array containing the tab definitions for all supported types
|
||||||
|
*
|
||||||
|
* Using array_keys on this array or isset allows to check whether a
|
||||||
|
* requested type is supported
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $supportedTypes = array(
|
||||||
|
self::TYPE_PDF => array(
|
||||||
|
'name' => 'pdf',
|
||||||
|
'title' => 'PDF',
|
||||||
|
'icon' => 'img/classic/application-pdf.png',
|
||||||
|
'urlParams' => array('filetype' => 'pdf')
|
||||||
|
),
|
||||||
|
self::TYPE_CSV => array(
|
||||||
|
'name' => 'csv',
|
||||||
|
'title' => 'CSV',
|
||||||
|
'icon' => 'img/classic/application-csv.png',
|
||||||
|
'urlParams' => array('filetype' => 'csv')
|
||||||
|
),
|
||||||
|
self::TYPE_JSON => array(
|
||||||
|
'name' => 'json',
|
||||||
|
'title' => 'JSON',
|
||||||
|
'icon' => 'img/classic/application-json.png',
|
||||||
|
'urlParams' => array('filetype' => 'json')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of tabs to be added to the dropdown area
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $tabs = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new OutputFormat extender
|
||||||
|
*
|
||||||
|
* In general, it's assumed that all types are supported when an outputFormat extension
|
||||||
|
* is added, so this class offers to remove specific types instead of adding ones
|
||||||
|
*
|
||||||
|
* @param array $disabled An array of output types to <b>not</b> show.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct(array $disabled = array())
|
||||||
|
{
|
||||||
|
foreach ($this->supportedTypes as $type => $values) {
|
||||||
|
if (in_array($type, $disabled)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isset($this->supportedTypes[$type])) {
|
||||||
|
Logger::error('Tried to add an unsupported output type: %s', $type);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tabConfig = $this->supportedTypes[$type];
|
||||||
|
$tabConfig["url"] = Url::fromRequest();
|
||||||
|
$this->tabs[] = new Tab($tabConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
foreach ($this->tabs as $tab) {
|
||||||
|
$tabs->addAsDropdown($tab->getName(), $tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
library/Icinga/Web/Widget/Tabextension/Tabextension.php
Normal file
49
library/Icinga/Web/Widget/Tabextension/Tabextension.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension interface that allows to extend a tabbar with reusable components.
|
||||||
|
*
|
||||||
|
* Tabs can be either extended by creating a tabextension and calling the apply method
|
||||||
|
* or by calling the tabs @see \Icinga\Web\Widget\Tabs::extend() method and providing
|
||||||
|
* a tab extension.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
interface Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Apply this tabextension to the provided tabs
|
||||||
|
*
|
||||||
|
* @param Tabs $tabs The tabbar to modify
|
||||||
|
**/
|
||||||
|
public function apply(Tabs $tabs);
|
||||||
|
}
|
@ -29,7 +29,8 @@
|
|||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Widget\Tabextension\Tabextension;
|
||||||
|
use Zend_View_Abstract;
|
||||||
|
|
||||||
use Countable;
|
use Countable;
|
||||||
|
|
||||||
@ -39,6 +40,33 @@ use Countable;
|
|||||||
*/
|
*/
|
||||||
class Tabs implements Countable, Widget
|
class Tabs implements Countable, Widget
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Template used for the base tabs
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $baseTpl =<<<'EOT'
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
{TABS}
|
||||||
|
{DROPDOWN}
|
||||||
|
</ul>
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template used for the tabs dropdown
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $dropdownTpl =<<<'EOT'
|
||||||
|
<li class="dropdown pull-right ">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-list-ul"> </i></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{TABS}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is where single tabs added to this container will be stored
|
* This is where single tabs added to this container will be stored
|
||||||
*
|
*
|
||||||
@ -54,19 +82,11 @@ class Tabs implements Countable, Widget
|
|||||||
private $active;
|
private $active;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name(s) going to be assigned to the <ul> element
|
* Array of tab names which should be displayed in a dropdown
|
||||||
*
|
*
|
||||||
* @var string
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $tab_class = 'nav-tabs';
|
private $dropdownTabs = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Array when special actions (dropdown) are enabled
|
|
||||||
* @TODO: Remove special part from tabs (Bug #4512)
|
|
||||||
*
|
|
||||||
* @var bool|array
|
|
||||||
*/
|
|
||||||
private $specialActions = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activate the tab with the given name
|
* Activate the tab with the given name
|
||||||
@ -87,18 +107,8 @@ class Tabs implements Countable, Widget
|
|||||||
}
|
}
|
||||||
$this->get($name)->setActive();
|
$this->get($name)->setActive();
|
||||||
$this->active = $name;
|
$this->active = $name;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
return $this;
|
||||||
throw new ProgrammingError(
|
|
||||||
sprintf(
|
|
||||||
"Cannot activate a tab that doesn't exist: %s. Available: %s",
|
|
||||||
$name,
|
|
||||||
empty($this->tabs)
|
|
||||||
? 'none'
|
|
||||||
: implode(', ', array_keys($this->tabs))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,12 +158,7 @@ class Tabs implements Countable, Widget
|
|||||||
public function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
if (!$this->has($name)) {
|
if (!$this->has($name)) {
|
||||||
throw new ProgrammingError(
|
return null;
|
||||||
sprintf(
|
|
||||||
'There is no such tab: %s',
|
|
||||||
$name
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $this->tabs[$name];
|
return $this->tabs[$name];
|
||||||
}
|
}
|
||||||
@ -207,84 +212,73 @@ class Tabs implements Countable, Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable special actions (dropdown with format, basket and dashboard)
|
* Add a tab to the dropdown on the right side of the tab-bar.
|
||||||
*
|
*
|
||||||
* @TODO: Remove special part from tabs (Bug #4512)
|
* @param $name
|
||||||
*
|
* @param $tab
|
||||||
* @return $this
|
|
||||||
*/
|
*/
|
||||||
public function enableSpecialActions()
|
public function addAsDropdown($name, $tab)
|
||||||
{
|
{
|
||||||
$this->specialActions = true;
|
$this->set($name, $tab);
|
||||||
return $this;
|
$this->dropdownTabs[] = $name;
|
||||||
|
$this->dropdownTabs = array_unique($this->dropdownTabs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the dropdown area with it's tabs and return the resulting HTML
|
||||||
|
*
|
||||||
|
* @param Zend_View_Abstract $view The view used for rendering
|
||||||
|
*
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
|
private function renderDropdownTabs(Zend_View_Abstract $view)
|
||||||
|
{
|
||||||
|
if (empty($this->dropdownTabs)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$tabs = '';
|
||||||
|
foreach ($this->dropdownTabs as $tabname) {
|
||||||
|
$tab = $this->get($tabname);
|
||||||
|
if ($tab === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tabs .= $tab->render($view);
|
||||||
|
}
|
||||||
|
return str_replace("{TABS}", $tabs, $this->dropdownTpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render all tabs, except the ones in dropdown area and return the resulting HTML
|
||||||
|
*
|
||||||
|
* @param Zend_View_Abstract $view The view used for rendering
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function renderTabs(Zend_View_Abstract $view)
|
||||||
|
{
|
||||||
|
$tabs = '';
|
||||||
|
foreach ($this->tabs as $name => $tab) {
|
||||||
|
// ignore tabs added to dropdown
|
||||||
|
if (in_array($name, $this->dropdownTabs)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tabs .= $tab->render($view);
|
||||||
|
}
|
||||||
|
return $tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Widget::render
|
* @see Widget::render
|
||||||
*/
|
*/
|
||||||
public function render(\Zend_View_Abstract $view)
|
public function render(Zend_View_Abstract $view)
|
||||||
{
|
{
|
||||||
if (empty($this->tabs)) {
|
if (empty($this->tabs)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$html = '<ul class="nav ' . $this->tab_class . '">' . PHP_EOL;
|
|
||||||
|
|
||||||
foreach ($this->tabs as $tab) {
|
$html = $this->baseTpl;
|
||||||
$html .= $tab->render($view);
|
$html = str_replace("{TABS}", $this->renderTabs($view), $html);
|
||||||
}
|
$html = str_replace("{DROPDOWN}", $this->renderDropdownTabs($view), $html);
|
||||||
|
|
||||||
// @TODO: Remove special part from tabs (Bug #4512)
|
|
||||||
$special = array();
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/application-pdf.png') . ' PDF',
|
|
||||||
Url::fromRequest(),
|
|
||||||
array('filetype' => 'pdf'),
|
|
||||||
array('target' => '_blank', 'quote' => false)
|
|
||||||
);
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/application-csv.png') . ' CSV',
|
|
||||||
Url::fromRequest(),
|
|
||||||
array('format' => 'csv'),
|
|
||||||
array('target' => '_blank', 'quote' => false)
|
|
||||||
);
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/application-json.png') . ' JSON',
|
|
||||||
Url::fromRequest(),
|
|
||||||
array('format' => 'json', 'quote' => false),
|
|
||||||
array('target' => '_blank', 'quote' => false)
|
|
||||||
);
|
|
||||||
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/basket.png') . ' URL Basket',
|
|
||||||
Url::fromPath('basket/add'),
|
|
||||||
array('url' => Url::fromRequest()->getRelativeUrl()),
|
|
||||||
array('quote' => false)
|
|
||||||
);
|
|
||||||
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/dashboard.png') . ' Dashboard',
|
|
||||||
Url::fromPath('dashboard/addurl'),
|
|
||||||
array('url' => Url::fromRequest()->getRelativeUrl()),
|
|
||||||
array('quote' => false)
|
|
||||||
);
|
|
||||||
// $auth = Auth::getInstance();
|
|
||||||
// if ($this->specialActions && ! empty($special) && $auth->isAuthenticated() && $auth->getUsername() === 'admin') {
|
|
||||||
if ($this->specialActions) {
|
|
||||||
$html .= '
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
';
|
|
||||||
|
|
||||||
foreach ($special as $shtml) {
|
|
||||||
$html .= '<li>' . $shtml . "</li>\n";
|
|
||||||
}
|
|
||||||
$html .= ' </ul>
|
|
||||||
</li>
|
|
||||||
';
|
|
||||||
|
|
||||||
}
|
|
||||||
$html .= "</ul>\n";
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,4 +303,17 @@ class Tabs implements Countable, Widget
|
|||||||
{
|
{
|
||||||
return $this->tabs;
|
return $this->tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply a Tabextension on this tabs object
|
||||||
|
*
|
||||||
|
* @param Tabextension $tabextension
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function extend(Tabextension $tabextension)
|
||||||
|
{
|
||||||
|
$tabextension->apply($this);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ use Icinga\Web\Hook;
|
|||||||
use Icinga\File\Csv;
|
use Icinga\File\Csv;
|
||||||
use Monitoring\Backend;
|
use Monitoring\Backend;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Web\Widget\Tabs;
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
use Icinga\Web\Widget\Tabextension\BasketAction;
|
||||||
|
|
||||||
class Monitoring_ListController extends ModuleActionController
|
class Monitoring_ListController extends ModuleActionController
|
||||||
{
|
{
|
||||||
@ -57,11 +59,9 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->view->tabs = $this->getTabs()
|
|
||||||
->activate($this->action_name)
|
|
||||||
->enableSpecialActions();
|
|
||||||
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
||||||
$this->view->grapher = Hook::get('grapher');
|
$this->view->grapher = Hook::get('grapher');
|
||||||
|
$this->createTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,9 +275,14 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
*
|
*
|
||||||
* @return Tabs
|
* @return Tabs
|
||||||
*/
|
*/
|
||||||
protected function getTabs()
|
protected function createTabs()
|
||||||
{
|
{
|
||||||
$tabs = new Tabs();
|
|
||||||
|
$tabs = $this->getTabs();
|
||||||
|
$tabs->extend(new OutputFormat())
|
||||||
|
->extend(new DashboardAction())
|
||||||
|
->extend(new BasketAction());
|
||||||
|
|
||||||
$tabs->add('services', array(
|
$tabs->add('services', array(
|
||||||
'title' => 'All services',
|
'title' => 'All services',
|
||||||
'icon' => 'img/classic/service.png',
|
'icon' => 'img/classic/service.png',
|
||||||
@ -290,9 +295,12 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
));
|
));
|
||||||
$tabs->add('downtimes', array(
|
$tabs->add('downtimes', array(
|
||||||
'title' => 'Downtimes',
|
'title' => 'Downtimes',
|
||||||
|
'usePost' => true,
|
||||||
'icon' => 'img/classic/downtime.gif',
|
'icon' => 'img/classic/downtime.gif',
|
||||||
'url' => 'monitoring/list/downtimes',
|
'url' => 'monitoring/list/downtimes',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$tabs->add('hostgroups', array(
|
$tabs->add('hostgroups', array(
|
||||||
'title' => 'Hostgroups',
|
'title' => 'Hostgroups',
|
||||||
@ -315,7 +323,6 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
'url' => 'monitoring/list/contactgroups',
|
'url' => 'monitoring/list/contactgroups',
|
||||||
));
|
));
|
||||||
*/
|
*/
|
||||||
return $tabs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,14 +33,16 @@ use Icinga\Web\Hook;
|
|||||||
use Monitoring\Object\Host;
|
use Monitoring\Object\Host;
|
||||||
use Monitoring\Object\Service;
|
use Monitoring\Object\Service;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Web\Widget\Tabs;
|
|
||||||
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
use Icinga\Web\Widget\Tabextension\BasketAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Monitoring_ShowController
|
* Class Monitoring_ShowController
|
||||||
*
|
*
|
||||||
* Actions for show context
|
* Actions for show context
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class Monitoring_ShowController extends ModuleActionController
|
class Monitoring_ShowController extends ModuleActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -82,7 +84,7 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->view->object = $object;
|
$this->view->object = $object;
|
||||||
$this->view->tabs = $this->createTabs();
|
$this->createTabs();
|
||||||
$this->prepareTicketHook();
|
$this->prepareTicketHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +95,6 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
{
|
{
|
||||||
Benchmark::measure('Entered service action');
|
Benchmark::measure('Entered service action');
|
||||||
$this->view->active = 'service';
|
$this->view->active = 'service';
|
||||||
$this->view->tabs->activate('service')->enableSpecialActions();
|
|
||||||
|
|
||||||
if ($grapher = Hook::get('grapher')) {
|
if ($grapher = Hook::get('grapher')) {
|
||||||
if ($grapher->hasGraph(
|
if ($grapher->hasGraph(
|
||||||
@ -209,7 +210,6 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
public function hostAction()
|
public function hostAction()
|
||||||
{
|
{
|
||||||
$this->view->active = 'host';
|
$this->view->active = 'host';
|
||||||
$this->view->tabs->activate('host')->enableSpecialActions();
|
|
||||||
|
|
||||||
if ($grapher = Hook::get('grapher')) {
|
if ($grapher = Hook::get('grapher')) {
|
||||||
if ($grapher->hasGraph($this->view->host->host_name)) {
|
if ($grapher->hasGraph($this->view->host->host_name)) {
|
||||||
@ -302,6 +302,7 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
->where('object_type', 'host')
|
->where('object_type', 'host')
|
||||||
->fetchPairs();
|
->fetchPairs();
|
||||||
$this->view->object->prefetch();
|
$this->view->object->prefetch();
|
||||||
|
$this->prepareTicketHook();
|
||||||
$this->prepareGrapherHook();
|
$this->prepareGrapherHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +427,7 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
protected function createTabs()
|
protected function createTabs()
|
||||||
{
|
{
|
||||||
$object = $this->view->object;
|
$object = $this->view->object;
|
||||||
$tabs = new Tabs();
|
$tabs = $this->getTabs();
|
||||||
if (!$this->view->host) {
|
if (!$this->view->host) {
|
||||||
return $tabs;
|
return $tabs;
|
||||||
}
|
}
|
||||||
@ -493,7 +494,9 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tabs->activate($this->action_name)->enableSpecialActions();
|
$tabs->extend(new OutputFormat())
|
||||||
|
->extend(new DashboardAction())
|
||||||
|
->extend(new BasketAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
$tabs->add('contacts', array(
|
$tabs->add('contacts', array(
|
||||||
@ -501,12 +504,8 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
'icon' => 'img/classic/customer.png',
|
'icon' => 'img/classic/customer.png',
|
||||||
'url' => 'monitoring/detail/contacts',
|
'url' => 'monitoring/detail/contacts',
|
||||||
'urlParams' => $params,
|
'urlParams' => $params,
|
||||||
));
|
));**/
|
||||||
*/
|
|
||||||
// TODO: Inventory 'img/classic/facts.gif'
|
|
||||||
// Ticket 'img/classic/ticket.gif'
|
|
||||||
// Customer 'img/classic/customer.png'
|
|
||||||
return $tabs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
|
|
||||||
use \Zend_Soap_Server as ZfSoapServer;
|
|
||||||
use \Zend_Soap_AutoDiscover as ZfSoapAutoDiscover;
|
|
||||||
use \Icinga\Web\Controller\ModuleActionController;
|
|
||||||
use \Icinga\Web\Url;
|
|
||||||
use \Monitoring\Backend;
|
|
||||||
|
|
||||||
|
|
||||||
class Api
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function problems()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$backend = Backend::getInstance('localdb');
|
|
||||||
$result = $backend->select()->from('status', array(
|
|
||||||
'host', 'service', 'host_state', 'service_state', 'service_output'
|
|
||||||
))->where('problems', 1)->fetchAll();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return array('error' => $e->getMessage());
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Monitoring_SoapController extends ModuleActionController
|
|
||||||
{
|
|
||||||
protected $handlesAuthentication = true;
|
|
||||||
|
|
||||||
public function indexAction()
|
|
||||||
{
|
|
||||||
$wsdl = new ZfSoapAutoDiscover();
|
|
||||||
$wsdl->setClass('Api');
|
|
||||||
if (isset($_GET['wsdl'])) {
|
|
||||||
$wsdl->handle();
|
|
||||||
} else {
|
|
||||||
$wsdl->dump('/tmp/test.wsdl');
|
|
||||||
$uri = 'http://itenos-devel.tom.local/' . Url::fromPath('monitoring/soap');
|
|
||||||
$server = new Zend_Soap_Server('/tmp/test.wsdl');
|
|
||||||
$server->setClass('Api');
|
|
||||||
$server->handle();
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// @codingStandardsIgnoreEnd
|
|
@ -28,7 +28,6 @@
|
|||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
use Icinga\Web\Controller\ModuleActionController;
|
use Icinga\Web\Controller\ModuleActionController;
|
||||||
use Icinga\Backend;
|
use Icinga\Backend;
|
||||||
use Icinga\Web\Widget\Tabs;
|
|
||||||
|
|
||||||
class Monitoring_SummaryController extends ModuleActionController
|
class Monitoring_SummaryController extends ModuleActionController
|
||||||
{
|
{
|
||||||
@ -39,13 +38,12 @@ class Monitoring_SummaryController extends ModuleActionController
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
||||||
$this->view->compact = $this->_getParam('view') === 'compact';
|
|
||||||
$this->view->tabs = $this->getTabs();
|
$this->view->tabs = $this->getTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTabs()
|
protected function createTabs()
|
||||||
{
|
{
|
||||||
$tabs = new Tabs();
|
$tabs = $this->getTabs();
|
||||||
$tabs->add('hostgroup', array(
|
$tabs->add('hostgroup', array(
|
||||||
'title' => 'Hostgroups',
|
'title' => 'Hostgroups',
|
||||||
'url' => 'monitoring/summary/group',
|
'url' => 'monitoring/summary/group',
|
||||||
@ -94,4 +92,4 @@ class Monitoring_SummaryController extends ModuleActionController
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$client = new SoapClient('http://itenos-devel.tom.local/monitoring/soap?wsdl', array(
|
|
||||||
'login' => 'icingaadmin',
|
|
||||||
'password' => 'tomtom',
|
|
||||||
'trace' => true,
|
|
||||||
'exceptions' => true,
|
|
||||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
|
||||||
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
|
|
||||||
// 'authentication' => SOAP_AUTHENTICATION_BASIC
|
|
||||||
|
|
||||||
));
|
|
||||||
|
|
||||||
// print_r($client->__getFunctions());
|
|
||||||
try {
|
|
||||||
print_r($client->problems());
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo $e->getMessage() . "\n\n";
|
|
||||||
echo $client->__getLastRequest() . "\n\n";
|
|
||||||
echo $client->__getLastResponse() . "\n\n";
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Combo
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class ComboTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Combo::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Combo::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Ido
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class IdoTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Ido::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Ido::GetSummary()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetSummary()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetSummary is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Ido::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Livestatus
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class LivestatusTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Livestatus::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Livestatus::Summary()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSummary()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSummary is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Livestatus::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Monitoringobjectlist
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class MonitoringobjectlistTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Current()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCurrent()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCurrent is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Next()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testNext()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testNext is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Key()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testKey()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testKey is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Valid()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testValid()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testValid is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Rewind()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRewind()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRewind is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::__isset()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__isset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__isset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend\Statusdat;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Servicelistquery
|
|
||||||
* Created Mon, 18 Feb 2013 14:33:21 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class ServicelistqueryTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for ServicelistQuery::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Statusdat
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class StatusdatTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Statusdat::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Statusdat::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Perfdata
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_PerfdataTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_Perfdata::Perfdata()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testPerfdata()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testPerfdata is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Qurl
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_QurlTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_QUrl::QUrl()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testQUrl()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQUrl is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
require_once('Zend/View/Helper/Abstract.php');
|
|
||||||
require_once('Zend/View.php');
|
|
||||||
|
|
||||||
require_once('../../application/views/helpers/Qlink.php');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Qlink
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_QlinkTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
public function testQlink()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQlink is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: Url handling has benn moved to `library\Icinga\Web\Url`. Replace following tests.
|
|
||||||
*/
|
|
||||||
// public function testURLPathParameter()
|
|
||||||
// {
|
|
||||||
// $view = new Zend_View();
|
|
||||||
//
|
|
||||||
// $helper = new Zend_View_Helper_Qlink();
|
|
||||||
// $helper->setView($view);
|
|
||||||
// $pathTpl = "/path/%s/to/%s";
|
|
||||||
// $this->assertEquals(
|
|
||||||
// "/path/param1/to/param2",
|
|
||||||
// $helper->getFormattedURL($pathTpl,array('param1','param2'))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public function testUrlGETParameter()
|
|
||||||
// {
|
|
||||||
// $view = new Zend_View();
|
|
||||||
// $helper = new Zend_View_Helper_Qlink();
|
|
||||||
// $helper->setView($view);
|
|
||||||
// $pathTpl = 'path';
|
|
||||||
// $this->assertEquals(
|
|
||||||
// '/path?param1=value1&param2=value2',
|
|
||||||
// $helper->getFormattedURL($pathTpl,array('param1'=>'value1','param2'=>'value2'))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public function testMixedParameters()
|
|
||||||
// {
|
|
||||||
// $view = new Zend_View();
|
|
||||||
// $helper = new Zend_View_Helper_Qlink();
|
|
||||||
// $helper->setView($view);
|
|
||||||
// $pathTpl = 'path/%s/to/%s';
|
|
||||||
// $this->assertEquals(
|
|
||||||
// '/path/path1/to/path2?param1=value1&param2=value2',
|
|
||||||
// $helper->getFormattedURL($pathTpl,array(
|
|
||||||
// 'path1','path2',
|
|
||||||
// 'param1'=>'value1',
|
|
||||||
// 'param2'=>'value2'))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // TODO: Test error case
|
|
||||||
// public function testWrongUrl() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Renderserviceperfdata
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_RenderserviceperfdataTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_RenderServicePerfdata::RenderServicePerfdata()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderServicePerfdata()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderServicePerfdata is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_RenderServicePerfdata::RenderDiskPie()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderDiskPie()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderDiskPie is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Timesince
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:14 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_TimesinceTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_TimeSince::TimeSince()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testTimeSince()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testTimeSince is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_TimeSince::ShowHourMin()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowHourMin()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowHourMin is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Monlib_Gui_Util
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:14 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Monlib_Gui_UtilTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowTimeSince()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowTimeSince()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowTimeSince is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowHourMin()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowHourMin()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowHourMin is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowSeconds()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowSeconds()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowSeconds is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowTime()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowTime()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowTime is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::GetHostStateClassName()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetHostStateClassName()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetHostStateClassName is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::GetHostStateName()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetHostStateName()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetHostStateName is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::GetServiceStateName()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetServiceStateName()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetServiceStateName is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Application;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Bootstrap
|
|
||||||
* Created Thu, 07 Feb 2013 10:07:13 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class BootstrapTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::AddModule()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testAddModule()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testAddModule is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetApplicationDir()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetApplicationDir()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetApplicationDir is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetModuleDir()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetModuleDir()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetModuleDir is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::HasModule()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasModule()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasModule is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::IsLegacy()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testIsLegacy()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testIsLegacy is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::IsRunningOnCli()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testIsRunningOnCli()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testIsRunningOnCli is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetLecacyBasedir()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetLecacyBasedir()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetLecacyBasedir is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Dispatch()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testDispatch()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testDispatch is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Cli()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCli()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCli is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::ForIcingaWeb1x()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testForIcingaWeb1x()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testForIcingaWeb1x is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Web()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testWeb()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testWeb is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Embedded()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testEmbedded()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testEmbedded is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetInstance()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetInstance()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetInstance is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Application;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Session
|
|
||||||
* Created Thu, 07 Feb 2013 10:07:13 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class SessionTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Session::GetInstance()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetInstance()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetInstance is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Authentication;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Credentials
|
|
||||||
* Created Mon, 10 Jun 2013 07:54:34 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class CredentialsTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::GetUsername()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetUsername()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetUsername is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::SetUsername()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSetUsername()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSetUsername is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::GetPassword()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetPassword()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetPassword is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::SetPassword()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSetPassword()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSetPassword is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::GetDomain()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDomain()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDomain is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::SetDomain()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSetDomain()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSetDomain is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Authentication;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Userbackend
|
|
||||||
* Created Fri, 07 Jun 2013 10:38:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class UserbackendTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for UserBackend::HasUsername()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasUsername()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasUsername is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for UserBackend::Authenticate()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testAuthenticate()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testAuthenticate is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Backend
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class BackendTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Backend::GetInstance()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetInstance()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetInstance is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Benchmark
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class BenchmarkTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::Measure()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testMeasure()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testMeasure is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::Reset()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testReset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testReset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::GetStartTime()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetStartTime()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetStartTime is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::Dump()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testDump()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testDump is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::RenderToText()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderToText()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderToText is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::RenderToHtml()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderToHtml()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderToHtml is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Format
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class FormatTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Format::Bytes()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testBytes()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testBytes is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Ido;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Db
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class DbTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Db::Module()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testModule()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testModule is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Db::GetDb()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDb()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDb is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Db::GetPrefix()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetPrefix()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetPrefix is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Connection
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class ConnectionTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::GetDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::Root()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRoot()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRoot is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::Select()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSelect()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSelect is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchOne()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchOne()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchOne is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchRow()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchRow()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchRow is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchAll()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchAll()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchAll is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Ldaputils
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class LdaputilsTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::ExplodeDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testExplodeDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testExplodeDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::ImplodeDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testImplodeDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testImplodeDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::QuoteForDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testQuoteForDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQuoteForDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::QuoteForSearch()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testQuoteForSearch()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQuoteForSearch is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Node
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class NodeTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::GetRDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetRDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetRDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::GetDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::__get()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__get()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__get is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::CreateWithRDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCreateWithRDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCreateWithRDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Root
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class RootTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::HasParent()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasParent()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasParent is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::GetConnection()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetConnection()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetConnection is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::HasBeenChanged()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasBeenChanged()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasBeenChanged is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::GetRDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetRDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetRDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::GetDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::__get()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__get()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__get is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::ForConnection()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testForConnection()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testForConnection is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -18,15 +18,6 @@ require_once('../../library/Icinga/Protocol/Livestatus/Query.php');
|
|||||||
class ConnectionTest extends TestCase
|
class ConnectionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::HasTable()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasTable()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasTable is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for Connection::Select()
|
* Test for Connection::Select()
|
||||||
*
|
*
|
||||||
@ -39,31 +30,4 @@ class ConnectionTest extends TestCase
|
|||||||
unlink($socket);
|
unlink($socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchAll()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchAll()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchAll is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::Disconnect()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testDisconnect()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testDisconnect is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::__destruct()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__destruct()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__destruct is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,148 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Livestatus;
|
|
||||||
|
|
||||||
use Icinga\Protocol\Livestatus\Connection;
|
|
||||||
use Icinga\Protocol\Livestatus\Query;
|
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
|
||||||
|
|
||||||
require_once('../../library/Icinga/Protocol/AbstractQuery.php');
|
|
||||||
require_once('../../library/Icinga/Protocol/Livestatus/Query.php');
|
|
||||||
require_once('../../library/Icinga/Protocol/Livestatus/Connection.php');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Query
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class QueryTest extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Compare()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCompare()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCompare is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasOrder()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasOrder()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasOrder is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Where()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testWhere()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testWhere is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Order()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testOrder()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testOrder is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Limit()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testLimit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testLimit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasLimit()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasLimit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasLimit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasOffset()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasOffset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasOffset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::GetLimit()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetLimit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetLimit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::GetOffset()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetOffset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetOffset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::From()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFrom()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFrom is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasColumns()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasColumns()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasColumns is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::GetColumns()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetColumns()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetColumns is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::__toString()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__toString()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__toString is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::__destruct()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__destruct()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__destruct is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Web\Controller\ActionController;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13,9 +13,18 @@ require_once '../../library/Icinga/Exception/ProgrammingError.php';
|
|||||||
|
|
||||||
use Icinga\Web\Hook\Configuration\ConfigurationTab;
|
use Icinga\Web\Hook\Configuration\ConfigurationTab;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabs;
|
use Icinga\Web\Widget\Tabs;
|
||||||
use PHPUnit_Framework_TestResult;
|
use PHPUnit_Framework_TestResult;
|
||||||
|
|
||||||
|
class RequestMock
|
||||||
|
{
|
||||||
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase
|
class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@ -23,12 +32,14 @@ class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
Hook::clean();
|
Hook::clean();
|
||||||
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
Hook::clean();
|
Hook::clean();
|
||||||
|
Url::$overwrittenRequest = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultTabs()
|
public function testDefaultTabs()
|
||||||
|
89
test/php/library/Icinga/Web/RequestMock.php
Normal file
89
test/php/library/Icinga/Web/RequestMock.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request mock that implements all methods required by the
|
||||||
|
* Url class
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class RequestMock
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The path of the request
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $path = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The baseUrl of the request
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $baseUrl = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of query parameters that the request should resemble
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $query = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path set for the request
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPathInfo()
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the baseUrl set for the request
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
|
return $this->baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the query set for the request
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getQuery()
|
||||||
|
{
|
||||||
|
return $this->query;
|
||||||
|
}
|
||||||
|
}
|
@ -2,69 +2,10 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Web;
|
namespace Tests\Icinga\Web;
|
||||||
require_once('../../library/Icinga/Web/Url.php');
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
require_once('library/Icinga/Web/RequestMock.php');
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
use Tests\Icinga\Web\RequestMock;
|
||||||
|
|
||||||
/**
|
|
||||||
* Request mock that implements all methods required by the
|
|
||||||
* Url class
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class RequestMock
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The path of the request
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $path = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The baseUrl of the request
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $baseUrl = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An array of query parameters that the request should resemble
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $query = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path set for the request
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPathInfo()
|
|
||||||
{
|
|
||||||
return $this->path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the baseUrl set for the request
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBaseUrl()
|
|
||||||
{
|
|
||||||
return $this->baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the query set for the request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getQuery()
|
|
||||||
{
|
|
||||||
return $this->query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the Icinga\Web\Url class that provides convenient access to Url manipulation method
|
* Tests for the Icinga\Web\Url class that provides convenient access to Url manipulation method
|
||||||
|
47
test/php/library/Icinga/Web/ViewMock.php
Normal file
47
test/php/library/Icinga/Web/ViewMock.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web;
|
||||||
|
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewMock that does absolutely nothing
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ViewMock extends Zend_View_Abstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* No operation is performed here
|
||||||
|
*/
|
||||||
|
protected function _run()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
164
test/php/library/Icinga/Web/Widget/TabTest.php
Normal file
164
test/php/library/Icinga/Web/Widget/TabTest.php
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web\Widget;
|
||||||
|
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Widget.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tab.php');
|
||||||
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
require_once('library/Icinga/Web/RequestMock.php');
|
||||||
|
require_once('library/Icinga/Web/ViewMock.php');
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
|
||||||
|
use Icinga\Web\View;
|
||||||
|
use Icinga\Web\Widget\Tab;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Tests\Icinga\Web\RequestMock;
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
use \PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
|
use Tests\Icinga\Web\ViewMock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test creation and rendering of tabs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class TabTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether rendering a tab without URL is done correctly
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testRenderWithoutUrl()
|
||||||
|
{
|
||||||
|
$tab = new Tab(array("name" => "tab", "title" => "Title text"));
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *> *Title text *<\/li> */i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
"Asserting an tab without url only showing a title, , got " . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether rendering an active tab adds the 'class' property
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testActiveTab()
|
||||||
|
{
|
||||||
|
$tab = new Tab(array("name" => "tab", "title" => "Title text"));
|
||||||
|
$tab->setActive(true);
|
||||||
|
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *class="active" *> *Title text *<\/li> */i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
"Asserting an active tab having the 'active' class provided, got " . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether rendering a tab with URL adds a n >a< tag correctly
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testTabWithUrl()
|
||||||
|
{
|
||||||
|
$tab = new Tab(
|
||||||
|
array(
|
||||||
|
"name" => "tab",
|
||||||
|
"title" => "Title text",
|
||||||
|
"url" => Url::fromPath("my/url", array(), new RequestMock())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *><a href="\/my\/url">Title text<\/a><\/li>/i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
'Asserting an url being rendered inside an HTML anchor. got ' . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test wheter the 'icon' property adds an img tag
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testTabWithIconImage()
|
||||||
|
{
|
||||||
|
$tab = new Tab(
|
||||||
|
array(
|
||||||
|
"name" => "tab",
|
||||||
|
"title" => "Title text",
|
||||||
|
"icon" => Url::fromPath("my/url", array(), new RequestMock())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *><img src="\/my\/url" .*?\/> Title text<\/li>/i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
'Asserting an url being rendered inside an HTML anchor. got ' . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test wheter the iconCls property adds an i tag with the icon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testTabWithIconClass()
|
||||||
|
{
|
||||||
|
$tab = new Tab(
|
||||||
|
array(
|
||||||
|
"name" => "tab",
|
||||||
|
"title" => "Title text",
|
||||||
|
"iconCls" => "myIcon"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *><i class="icon-myIcon"><\/i> Title text<\/li>/i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
'Asserting an url being rendered inside an HTML anchor. got ' . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Widget.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tab.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabs.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabextension/TabExtension.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabextension/OutputFormat.php');
|
||||||
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
|
||||||
|
require_once('library/Icinga/Web/RequestMock.php');
|
||||||
|
require_once('library/Icinga/Web/ViewMock.php');
|
||||||
|
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
|
||||||
|
use Icinga\Web\View;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
use Tests\Icinga\Web\RequestMock;
|
||||||
|
use Tests\Icinga\Web\ViewMock;
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for the OutputFormat Tabextension
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class OutputFormatTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test if a simple apply adds all tabs from the extender
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testApply()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
|
$tabs->extend(new OutputFormat());
|
||||||
|
$this->assertEquals(3, $tabs->count(), "Asserting new tabs being available after extending the tab bar");
|
||||||
|
Url::$overwrittenRequest = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if an apply with disabled output formats doesn't add these tabs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testDisableOutputFormat()
|
||||||
|
{
|
||||||
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
|
$tabs = new Tabs();
|
||||||
|
$tabs->extend(new OutputFormat(array(OutputFormat::TYPE_PDF)));
|
||||||
|
$this->assertEquals(
|
||||||
|
2,
|
||||||
|
$tabs->count(),
|
||||||
|
"Asserting two tabs being available after extending the tab bar and ignoring PDF"
|
||||||
|
);
|
||||||
|
Url::$overwrittenRequest = null;
|
||||||
|
}
|
||||||
|
}
|
111
test/php/library/Icinga/Web/Widget/TabsTest.php
Normal file
111
test/php/library/Icinga/Web/Widget/TabsTest.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?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}}}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web\Widget;
|
||||||
|
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Widget.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tab.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabs.php');
|
||||||
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
|
||||||
|
require_once('library/Icinga/Web/ViewMock.php');
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
|
||||||
|
use Icinga\Web\View;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
use Tests\Icinga\Web\ViewMock;
|
||||||
|
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
use \PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test rendering of tabs and corretct tab management
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class TabsTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test adding tabs and asserting for correct count
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testAddTabs()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
$this->assertEquals(0, $tabs->count(), 'Asserting a tab bar starting with no items');
|
||||||
|
$tabs->add('tab1', array('title' => 'Tab 1'));
|
||||||
|
$tabs->add('tab2', array('title' => 'Tab 2'));
|
||||||
|
$this->assertEquals(2, $tabs->count(), 'Asserting a tab bar containing 2 items after being added');
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$tabs->has('tab1'),
|
||||||
|
'Asserting the tab bar to determine the existence of added tabs correctly (tab1)'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$tabs->has('tab2'),
|
||||||
|
'Asserting the tab bar to determine the existence of added tabs correctly (tab2)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test rendering of tabs when no dropdown is requested
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testRenderTabsWithoutDropdown()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
|
||||||
|
$tabs->add('tab1', array('title' => 'Tab 1'));
|
||||||
|
$tabs->add('tab2', array('title' => 'Tab 2'));
|
||||||
|
|
||||||
|
$html = $tabs->render(new ViewMock());
|
||||||
|
$this->assertContains('<li >Tab 1</li>', $html, 'Asserting tab 1 being rendered correctly' . $html);
|
||||||
|
$this->assertContains('<li >Tab 2</li>', $html, 'Asserting tab 2 being rendered correctly' . $html);
|
||||||
|
$this->assertNotContains('class="dropdown ', 'Asserting the dropdown to not be rendered' . $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test rendering of tabs when dropdown is requested
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testRenderDropdown()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
|
||||||
|
$tabs->add('tab1', array('title' => 'Tab 1'));
|
||||||
|
$tabs->addAsDropdown('tab2', array('title' => 'Tab 2'));
|
||||||
|
|
||||||
|
$html = $tabs->render(new ViewMock());
|
||||||
|
$this->assertContains('<li >Tab 1</li>', $html, 'Asserting tab 1 being rendered correctly ' . $html);
|
||||||
|
$this->assertContains('<li >Tab 2</li>', $html, 'Asserting tab 2 being rendered correctly ' . $html);
|
||||||
|
$this->assertContains('class="dropdown ', 'Asserting the dropdown to be rendered, got ' . $html);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user