commit
4658405990
|
@ -127,13 +127,15 @@ class DbBackendForm extends BaseBackendForm
|
|||
{
|
||||
try {
|
||||
$name = $this->getBackendName();
|
||||
$dbBackend = new DbUserBackend(new Zend_Config(
|
||||
array(
|
||||
'backend' => 'db',
|
||||
'target' => 'user',
|
||||
'resource' => $this->getValue('backend_' . $this->filterName($name) . '_resource'),
|
||||
$dbBackend = new DbUserBackend(
|
||||
new Zend_Config(
|
||||
array(
|
||||
'backend' => 'db',
|
||||
'target' => 'user',
|
||||
'resource' => $this->getValue('backend_' . $this->filterName($name) . '_resource'),
|
||||
)
|
||||
)
|
||||
));
|
||||
);
|
||||
if ($dbBackend->getUserCount() < 1) {
|
||||
$this->addErrorMessage("No users found under the specified database backend");
|
||||
return false;
|
||||
|
|
|
@ -272,9 +272,9 @@ class Module
|
|||
$moduleName = ucfirst($this->getName());
|
||||
$moduleLibraryDir = $this->getLibDir(). '/'. $moduleName;
|
||||
|
||||
$this->app->getLoader()->registerNamespace($moduleName, $moduleLibraryDir);
|
||||
$this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir);
|
||||
if (is_dir($this->getFormDir())) {
|
||||
$this->app->getLoader()->registerNamespace($moduleName. '\\Form', $this->getFormDir());
|
||||
$this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Form', $this->getFormDir());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace Icinga\Protocol\Statusdat;
|
|||
|
||||
use Icinga\Protocol;
|
||||
use Icinga\Data\AbstractQuery;
|
||||
|
||||
/**
|
||||
* Class Query
|
||||
* @package Icinga\Protocol\Statusdat
|
||||
|
@ -398,5 +399,4 @@ class Query extends AbstractQuery
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,9 +30,10 @@ namespace Icinga\Protocol\Statusdat;
|
|||
|
||||
|
||||
use Icinga\Data\DatasourceInterface;
|
||||
use Icinga\Exception as Exception;
|
||||
use Icinga\Benchmark as Benchmark;
|
||||
use Icinga\Exception;
|
||||
use Icinga\Benchmark;
|
||||
use Icinga\Protocol\Statusdat\View\MonitoringObjectList;
|
||||
|
||||
/**
|
||||
* Class Reader
|
||||
* @package Icinga\Protocol\Statusdat
|
||||
|
@ -319,5 +320,4 @@ class Reader implements IReader, DatasourceInterface
|
|||
{
|
||||
return isset($this->lastState[$type]) ? array_keys($this->lastState[$type]) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,15 +11,21 @@
|
|||
* If the dataset contains arrays instead of objects, they will be cast to objects.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Icinga\Protocol\Statusdat\View;
|
||||
|
||||
class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess
|
||||
use \Iterator;
|
||||
use \Countable;
|
||||
use \ArrayAccess;
|
||||
use \Exception;
|
||||
|
||||
class MonitoringObjectList implements Iterator, Countable, ArrayAccess
|
||||
{
|
||||
private $dataSet = array();
|
||||
private $position = 0;
|
||||
private $dataView = null;
|
||||
|
||||
function __construct(array &$dataset, AccessorStrategy $dataView = null)
|
||||
public function __construct(array &$dataset, AccessorStrategy $dataView = null)
|
||||
{
|
||||
$this->dataSet = $dataset;
|
||||
$this->position = 0;
|
||||
|
@ -44,8 +50,9 @@ class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess
|
|||
*/
|
||||
public function current()
|
||||
{
|
||||
if ($this->dataView)
|
||||
if ($this->dataView) {
|
||||
return $this;
|
||||
}
|
||||
return $this->dataSet[$this->position];
|
||||
}
|
||||
|
||||
|
@ -96,17 +103,17 @@ class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess
|
|||
|
||||
public function __isset($name)
|
||||
{
|
||||
return $this->dataView->exists($this->dataSet[$this->position],$name);
|
||||
return $this->dataView->exists($this->dataSet[$this->position], $name);
|
||||
}
|
||||
|
||||
function __get($name)
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->dataView->get($this->dataSet[$this->position],$name);
|
||||
return $this->dataView->get($this->dataSet[$this->position], $name);
|
||||
}
|
||||
|
||||
function __set($name, $value)
|
||||
public function __set($name, $value)
|
||||
{
|
||||
throw new \Exception("Setting is currently not available for objects");
|
||||
throw new Exception("Setting is currently not available for objects");
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
|
@ -130,5 +137,4 @@ class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess
|
|||
{
|
||||
// non mutable
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class ObjectRemappingView implements AccessorStrategy
|
|||
|
||||
/**
|
||||
* When implementing your own Mapper, this contains the static mapping rules.
|
||||
* @see Monitoring\Backend\Statusdat\DataView\StatusdatServiceView for an example
|
||||
* @see Icinga\Module\Monitoring\Backend\Statusdat\DataView\StatusdatServiceView for an example
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -99,8 +99,9 @@ class ObjectRemappingView implements AccessorStrategy
|
|||
|
||||
private function applyPropertyFunction($function, $value)
|
||||
{
|
||||
if (!isset($this->functionMap[$function]))
|
||||
if (!isset($this->functionMap[$function])) {
|
||||
return $value;
|
||||
}
|
||||
$fn = $this->functionMap[$function];
|
||||
|
||||
return $this->$fn($value);
|
||||
|
|
|
@ -26,382 +26,371 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Test;
|
||||
namespace {
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
|
||||
require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
require_once 'DbTest.php';
|
||||
require_once 'FormTest.php';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
use \Exception;
|
||||
use \RuntimeException;
|
||||
use \Zend_Test_PHPUnit_ControllerTestCase;
|
||||
use \Zend_Config;
|
||||
use \Zend_Db_Adapter_Pdo_Abstract;
|
||||
use \Zend_Db_Adapter_Pdo_Mysql;
|
||||
use \Zend_Db_Adapter_Pdo_Pgsql;
|
||||
use \Zend_Db_Adapter_Pdo_Oci;
|
||||
use \Icinga\Application\DbAdapterFactory;
|
||||
use \Icinga\User\Preferences;
|
||||
use \Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
* Class BaseTestCase
|
||||
*/
|
||||
class BaseTestCase extends Zend_Test_PHPUnit_ControllerTestCase implements DbTest, FormTest
|
||||
{
|
||||
/**
|
||||
* Path to application/
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $appDir;
|
||||
|
||||
/**
|
||||
* Path to library/Icinga
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $libDir;
|
||||
|
||||
/**
|
||||
* Path to etc/
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
public static $etcDir;
|
||||
|
||||
/**
|
||||
* Path to test/php/
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $testDir;
|
||||
|
||||
/**
|
||||
* Path to share/icinga2-web
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $shareDir;
|
||||
|
||||
/**
|
||||
* Path to modules/
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $moduleDir;
|
||||
|
||||
/**
|
||||
* DbAdapterFactory configuration for different database types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $dbConfiguration = array(
|
||||
'mysql' => array(
|
||||
'type' => 'db',
|
||||
'db' => 'mysql',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 3306,
|
||||
'dbname' => 'icinga_unittest',
|
||||
'username' => 'icinga_unittest',
|
||||
'password' => 'icinga_unittest'
|
||||
),
|
||||
'pgsql' => array(
|
||||
'type' => 'db',
|
||||
'db' => 'pgsql',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 5432,
|
||||
'dbname' => 'icinga_unittest',
|
||||
'username' => 'icinga_unittest',
|
||||
'password' => 'icinga_unittest'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a test case with the given name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @param string $dataName
|
||||
* @see PHPUnit_Framework_TestCase::__construct
|
||||
*/
|
||||
public function __construct($name = null, array $data = array(), $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
$tz = @date_default_timezone_get();
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup test path environment
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function setupDirectories()
|
||||
{
|
||||
static $initialized = false;
|
||||
|
||||
if ($initialized === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$baseDir = realpath(__DIR__ . '/../../../');
|
||||
|
||||
if ($baseDir === false) {
|
||||
throw new RuntimeException('Application base dir not found');
|
||||
}
|
||||
|
||||
self::$appDir = $baseDir . '/application';
|
||||
self::$libDir = $baseDir . '/library/Icinga';
|
||||
self::$etcDir = $baseDir . '/etc';
|
||||
self::$testDir = $baseDir . '/test/php';
|
||||
self::$shareDir = $baseDir . '/share/icinga2-web';
|
||||
self::$moduleDir = $baseDir . '/modules';
|
||||
|
||||
$initialized = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Zend_Config for database configuration
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Zend_Config
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function createDbConfigFor($name)
|
||||
{
|
||||
if (array_key_exists($name, self::$dbConfiguration)) {
|
||||
return new Zend_Config(self::$dbConfiguration[$name]);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Configuration for database type not available: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of Zend Database Adapter
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function createDbAdapterFor($name)
|
||||
{
|
||||
$this->requireDbLibraries();
|
||||
|
||||
try {
|
||||
$adapter = DbAdapterFactory::createDbAdapter($this->createDbConfigFor($name));
|
||||
} catch (Exception $e) {
|
||||
$adapter = $e->getMessage();
|
||||
}
|
||||
|
||||
return array(
|
||||
array($adapter)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit provider for mysql
|
||||
*
|
||||
* @return Zend_Db_Adapter_Pdo_Mysql
|
||||
*/
|
||||
public function mysqlDb()
|
||||
{
|
||||
return $this->createDbAdapterFor('mysql');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit provider for pgsql
|
||||
*
|
||||
* @return Zend_Db_Adapter_Pdo_Pgsql
|
||||
*/
|
||||
public function pgsqlDb()
|
||||
{
|
||||
return $this->createDbAdapterFor('pgsql');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit provider for oracle
|
||||
*
|
||||
* @return Zend_Db_Adapter_Pdo_Oci
|
||||
*/
|
||||
public function oracleDb()
|
||||
{
|
||||
return $this->createDbAdapterFor('oracle');
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes sql file on PDO object
|
||||
*
|
||||
* @param Zend_Db_Adapter_Pdo_Abstract $resource
|
||||
* @param string $filename
|
||||
*
|
||||
* @return boolean Operational success flag
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function loadSql(Zend_Db_Adapter_Pdo_Abstract $resource, $filename)
|
||||
{
|
||||
if (!is_file($filename)) {
|
||||
throw new RuntimeException(
|
||||
'Sql file not found: ' . $filename . ' (test=' . $this->getName() . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$sqlData = file_get_contents($filename);
|
||||
|
||||
if (!$sqlData) {
|
||||
throw new RuntimeException(
|
||||
'Sql file is empty: ' . $filename . ' (test=' . $this->getName() . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$resource->exec($sqlData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup provider for testcase
|
||||
*
|
||||
* @param string|Zend_Db_Adapter_PDO_Abstract|null $resource
|
||||
*/
|
||||
public function setupDbProvider($resource)
|
||||
{
|
||||
if (!$resource instanceof Zend_Db_Adapter_Pdo_Abstract) {
|
||||
if (is_string($resource)) {
|
||||
$this->markTestSkipped('Could not initialize provider: ' . $resource);
|
||||
} else {
|
||||
$this->markTestSkipped('Could not initialize provider');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$resource->getConnection();
|
||||
} catch (Exception $e) {
|
||||
$this->markTestSkipped('Could not connect to provider: '. $e->getMessage());
|
||||
}
|
||||
|
||||
$tables = $resource->listTables();
|
||||
foreach ($tables as $table) {
|
||||
$resource->exec('DROP TABLE ' . $table . ';');
|
||||
if (!function_exists('t')) {
|
||||
function t()
|
||||
{
|
||||
return func_get_arg(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a new form object
|
||||
*
|
||||
* @param string $formClass Form class to instantiate
|
||||
* @param array $requestData Request data for the form
|
||||
*
|
||||
* @return Form
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function createForm($formClass, array $requestData = array())
|
||||
{
|
||||
$this->requireFormLibraries();
|
||||
|
||||
$classParts = explode('\\', $formClass);
|
||||
$identifier = array_shift($classParts);
|
||||
array_shift($classParts); // Throw away
|
||||
$fixedPathComponent = '/forms';
|
||||
|
||||
if (strtolower($identifier) == 'icinga') {
|
||||
$startPathComponent = self::$appDir . $fixedPathComponent;
|
||||
} else {
|
||||
$startPathComponent = self::$moduleDir
|
||||
. '/'
|
||||
. strtolower($identifier)
|
||||
. '/application'
|
||||
.$fixedPathComponent;
|
||||
if (!function_exists('mt')) {
|
||||
function mt()
|
||||
{
|
||||
return func_get_arg(0);
|
||||
}
|
||||
|
||||
$classFile = $startPathComponent . '/' . implode('/', $classParts) . '.php';
|
||||
|
||||
if (!file_exists($classFile)) {
|
||||
throw new RuntimeException('Class file for form "' . $formClass . '" not found');
|
||||
}
|
||||
|
||||
require_once $classFile;
|
||||
$form = new $formClass();
|
||||
$form->initCsrfToken();
|
||||
|
||||
$token = $form->getValue($form->getTokenElementName());
|
||||
if ($token !== null) {
|
||||
$requestData[$form->getTokenElementName()] = $token;
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
$request->setMethod('POST');
|
||||
$request->setPost($requestData);
|
||||
|
||||
$form->setRequest($request);
|
||||
$form->setUserPreferences(
|
||||
new Preferences(
|
||||
array()
|
||||
)
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require all libraries to instantiate forms
|
||||
*/
|
||||
public function requireFormLibraries()
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once 'Zend/Form/Decorator/Abstract.php';
|
||||
require_once 'Zend/Validate/Abstract.php';
|
||||
require_once 'Zend/Form/Element/Xhtml.php';
|
||||
require_once 'Zend/Form/Element/Text.php';
|
||||
require_once 'Zend/Form/Element/Submit.php';
|
||||
require_once 'Zend/Form.php';
|
||||
require_once 'Zend/View.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/InvalidCSRFTokenException.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/Element/DateTimePicker.php';
|
||||
require_once self::$libDir . '/Web/Form/Element/Note.php';
|
||||
require_once self::$libDir . '/Web/Form/Element/Number.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/Decorator/ConditionalHidden.php';
|
||||
require_once self::$libDir . '/Web/Form/Decorator/HelpText.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/Validator/DateFormatValidator.php';
|
||||
require_once self::$libDir . '/Web/Form/Validator/TimeFormatValidator.php';
|
||||
require_once self::$libDir . '/Web/Form/Validator/WritablePathValidator.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form.php';
|
||||
|
||||
require_once self::$libDir . '/User/Preferences.php';
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* Require all classes for database adapter creation
|
||||
*/
|
||||
public function requireDbLibraries()
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
require_once 'Zend/Config.php';
|
||||
require_once 'Zend/Db.php';
|
||||
require_once 'Zend/Log.php';
|
||||
|
||||
require_once realpath(self::$libDir . '/Exception/ConfigurationError.php');
|
||||
require_once realpath(self::$libDir . '/Util/ConfigAwareFactory.php');
|
||||
require_once realpath(self::$libDir . '/Application/DbAdapterFactory.php');
|
||||
require_once realpath(self::$libDir . '/Application/Logger.php');
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
BaseTestCase::setupDirectories();
|
||||
// @codingStandardsIgnoreEnd
|
||||
namespace Icinga\Test {
|
||||
|
||||
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
|
||||
require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
require_once 'DbTest.php';
|
||||
require_once 'FormTest.php';
|
||||
// @codingStandardsIgnoreStart
|
||||
use \Exception;
|
||||
use \RuntimeException;
|
||||
use Zend_Test_PHPUnit_ControllerTestCase;
|
||||
use Zend_Config;
|
||||
use Zend_Db_Adapter_Pdo_Abstract;
|
||||
use Zend_Db_Adapter_Pdo_Mysql;
|
||||
use Zend_Db_Adapter_Pdo_Pgsql;
|
||||
use Zend_Db_Adapter_Pdo_Oci;
|
||||
use Icinga\Application\DbAdapterFactory;
|
||||
use Icinga\User\Preferences;
|
||||
use Icinga\Web\Form;
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* Class BaseTestCase
|
||||
*/
|
||||
class BaseTestCase extends Zend_Test_PHPUnit_ControllerTestCase implements DbTest, FormTest
|
||||
{
|
||||
/**
|
||||
* Path to application/
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $appDir;
|
||||
|
||||
/**
|
||||
* Path to library/Icinga
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $libDir;
|
||||
|
||||
/**
|
||||
* Path to etc/
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
public static $etcDir;
|
||||
|
||||
/**
|
||||
* Path to test/php/
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $testDir;
|
||||
|
||||
/**
|
||||
* Path to share/icinga2-web
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $shareDir;
|
||||
|
||||
/**
|
||||
* Path to modules/
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $moduleDir;
|
||||
|
||||
/**
|
||||
* DbAdapterFactory configuration for different database types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $dbConfiguration = array(
|
||||
'mysql' => array(
|
||||
'type' => 'db',
|
||||
'db' => 'mysql',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 3306,
|
||||
'dbname' => 'icinga_unittest',
|
||||
'username' => 'icinga_unittest',
|
||||
'password' => 'icinga_unittest'
|
||||
),
|
||||
'pgsql' => array(
|
||||
'type' => 'db',
|
||||
'db' => 'pgsql',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 5432,
|
||||
'dbname' => 'icinga_unittest',
|
||||
'username' => 'icinga_unittest',
|
||||
'password' => 'icinga_unittest'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs a test case with the given name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @param string $dataName
|
||||
* @see PHPUnit_Framework_TestCase::__construct
|
||||
*/
|
||||
public function __construct($name = null, array $data = array(), $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
date_default_timezone_set('UTC');
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup test path environment
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function setupDirectories()
|
||||
{
|
||||
static $initialized = false;
|
||||
|
||||
if ($initialized === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$baseDir = realpath(__DIR__ . '/../../../');
|
||||
|
||||
if ($baseDir === false) {
|
||||
throw new RuntimeException('Application base dir not found');
|
||||
}
|
||||
|
||||
self::$appDir = $baseDir . '/application';
|
||||
self::$libDir = $baseDir . '/library/Icinga';
|
||||
self::$etcDir = $baseDir . '/etc';
|
||||
self::$testDir = $baseDir . '/test/php';
|
||||
self::$shareDir = $baseDir . '/share/icinga2-web';
|
||||
self::$moduleDir = $baseDir . '/modules';
|
||||
|
||||
$initialized = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Zend_Config for database configuration
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Zend_Config
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function createDbConfigFor($name)
|
||||
{
|
||||
if (array_key_exists($name, self::$dbConfiguration)) {
|
||||
return new Zend_Config(self::$dbConfiguration[$name]);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Configuration for database type not available: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of Zend Database Adapter
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function createDbAdapterFor($name)
|
||||
{
|
||||
$this->requireDbLibraries();
|
||||
|
||||
try {
|
||||
$adapter = DbAdapterFactory::createDbAdapter($this->createDbConfigFor($name));
|
||||
} catch (Exception $e) {
|
||||
$adapter = $e->getMessage();
|
||||
}
|
||||
|
||||
return array(
|
||||
array($adapter)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit provider for mysql
|
||||
*
|
||||
* @return Zend_Db_Adapter_Pdo_Mysql
|
||||
*/
|
||||
public function mysqlDb()
|
||||
{
|
||||
return $this->createDbAdapterFor('mysql');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit provider for pgsql
|
||||
*
|
||||
* @return Zend_Db_Adapter_Pdo_Pgsql
|
||||
*/
|
||||
public function pgsqlDb()
|
||||
{
|
||||
return $this->createDbAdapterFor('pgsql');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit provider for oracle
|
||||
*
|
||||
* @return Zend_Db_Adapter_Pdo_Oci
|
||||
*/
|
||||
public function oracleDb()
|
||||
{
|
||||
return $this->createDbAdapterFor('oracle');
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes sql file on PDO object
|
||||
*
|
||||
* @param Zend_Db_Adapter_Pdo_Abstract $resource
|
||||
* @param string $filename
|
||||
*
|
||||
* @return boolean Operational success flag
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function loadSql(Zend_Db_Adapter_Pdo_Abstract $resource, $filename)
|
||||
{
|
||||
if (!is_file($filename)) {
|
||||
throw new RuntimeException(
|
||||
'Sql file not found: ' . $filename . ' (test=' . $this->getName() . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$sqlData = file_get_contents($filename);
|
||||
|
||||
if (!$sqlData) {
|
||||
throw new RuntimeException(
|
||||
'Sql file is empty: ' . $filename . ' (test=' . $this->getName() . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$resource->exec($sqlData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup provider for testcase
|
||||
*
|
||||
* @param string|Zend_Db_Adapter_PDO_Abstract|null $resource
|
||||
*/
|
||||
public function setupDbProvider($resource)
|
||||
{
|
||||
if (!$resource instanceof Zend_Db_Adapter_Pdo_Abstract) {
|
||||
if (is_string($resource)) {
|
||||
$this->markTestSkipped('Could not initialize provider: ' . $resource);
|
||||
} else {
|
||||
$this->markTestSkipped('Could not initialize provider');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$resource->getConnection();
|
||||
} catch (Exception $e) {
|
||||
$this->markTestSkipped('Could not connect to provider: '. $e->getMessage());
|
||||
}
|
||||
|
||||
$tables = $resource->listTables();
|
||||
foreach ($tables as $table) {
|
||||
$resource->exec('DROP TABLE ' . $table . ';');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a form
|
||||
*
|
||||
* If the form has CSRF protection enabled, creates the form's token element and adds the generated token to the
|
||||
* request data
|
||||
*
|
||||
* @param string $formClass Qualified class name of the form to create. Note that the class has to be
|
||||
* defined as no attempt is made to require the class before instantiating.
|
||||
* @param array $requestData Request data for the form
|
||||
*
|
||||
* @return Form
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function createForm($formClass, array $requestData = array())
|
||||
{
|
||||
$form = new $formClass;
|
||||
// If the form has CSRF protection enabled, add the token to the request data, else all calls to
|
||||
// isSubmittedAndValid will fail
|
||||
$form->initCsrfToken();
|
||||
$token = $form->getValue($form->getTokenElementName());
|
||||
if ($token !== null) {
|
||||
$requestData[$form->getTokenElementName()] = $token;
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
$request->setMethod('POST');
|
||||
$request->setPost($requestData);
|
||||
$form->setRequest($request);
|
||||
$form->setUserPreferences(
|
||||
new Preferences(
|
||||
array()
|
||||
)
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require all libraries to instantiate forms
|
||||
*/
|
||||
public static function requireFormLibraries()
|
||||
{
|
||||
require_once 'Zend/Form/Decorator/Abstract.php';
|
||||
require_once 'Zend/Validate/Abstract.php';
|
||||
require_once 'Zend/Form/Element/Xhtml.php';
|
||||
require_once 'Zend/Form/Element/Text.php';
|
||||
require_once 'Zend/Form/Element/Submit.php';
|
||||
require_once 'Zend/Form/Element/Checkbox.php';
|
||||
require_once 'Zend/Form.php';
|
||||
require_once 'Zend/View.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/InvalidCSRFTokenException.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/Element/DateTimePicker.php';
|
||||
require_once self::$libDir . '/Web/Form/Element/Note.php';
|
||||
require_once self::$libDir . '/Web/Form/Element/Number.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/Decorator/ConditionalHidden.php';
|
||||
require_once self::$libDir . '/Web/Form/Decorator/HelpText.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form/Validator/DateFormatValidator.php';
|
||||
require_once self::$libDir . '/Web/Form/Validator/TimeFormatValidator.php';
|
||||
require_once self::$libDir . '/Web/Form/Validator/WritablePathValidator.php';
|
||||
|
||||
require_once self::$libDir . '/Web/Form.php';
|
||||
|
||||
require_once self::$libDir . '/User/Preferences.php';
|
||||
require_once self::$libDir . '/User/Preferences/ChangeSet.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Require all classes for database adapter creation
|
||||
*/
|
||||
public static function requireDbLibraries()
|
||||
{
|
||||
require_once 'Zend/Config.php';
|
||||
require_once 'Zend/Db.php';
|
||||
require_once 'Zend/Log.php';
|
||||
|
||||
require_once self::$libDir . '/Exception/ConfigurationError.php';
|
||||
require_once self::$libDir . '/Util/ConfigAwareFactory.php';
|
||||
require_once self::$libDir . '/Application/DbAdapterFactory.php';
|
||||
require_once self::$libDir . '/Application/Logger.php';
|
||||
}
|
||||
}
|
||||
|
||||
BaseTestCase::setupDirectories();
|
||||
BaseTestCase::requireFormLibraries();
|
||||
BaseTestcase::requireDbLibraries();
|
||||
}
|
||||
|
|
|
@ -44,9 +44,4 @@ interface FormTest
|
|||
* @return Form
|
||||
*/
|
||||
public function createForm($formClass, array $requestData = array());
|
||||
|
||||
/**
|
||||
* Require all libraries to instantiate forms
|
||||
*/
|
||||
public function requireFormLibraries();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,9 @@ class Format
|
|||
|
||||
public static function duration($duration)
|
||||
{
|
||||
if (! $duration) return '-';
|
||||
if (! $duration) {
|
||||
return '-';
|
||||
}
|
||||
return self::showHourMin($duration);
|
||||
}
|
||||
|
||||
|
@ -67,7 +69,9 @@ class Format
|
|||
|
||||
public static function timeSince($timestamp)
|
||||
{
|
||||
if (! $timestamp) return '-';
|
||||
if (! $timestamp) {
|
||||
return '-';
|
||||
}
|
||||
$duration = time() - $timestamp;
|
||||
$prefix = '';
|
||||
if ($duration < 0) {
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use \Icinga\Application\Icinga;
|
||||
use \Monitoring\Backend;
|
||||
use \Icinga\Application\Config;
|
||||
use \Icinga\Application\Logger;
|
||||
use \Icinga\Web\Form;
|
||||
|
@ -36,15 +35,16 @@ use \Icinga\Web\Controller\ActionController;
|
|||
use \Icinga\Protocol\Commandpipe\CommandPipe;
|
||||
use \Icinga\Exception\ConfigurationError;
|
||||
use \Icinga\Exception\MissingParameterException;
|
||||
use \Monitoring\Form\Command\AcknowledgeForm;
|
||||
use \Monitoring\Form\Command\CommentForm;
|
||||
use \Monitoring\Form\Command\CommandForm;
|
||||
use \Monitoring\Form\Command\CommandWithIdentifierForm;
|
||||
use \Monitoring\Form\Command\CustomNotificationForm;
|
||||
use \Monitoring\Form\Command\DelayNotificationForm;
|
||||
use \Monitoring\Form\Command\RescheduleNextCheckForm;
|
||||
use \Monitoring\Form\Command\ScheduleDowntimeForm;
|
||||
use \Monitoring\Form\Command\SubmitPassiveCheckResultForm;
|
||||
use \Icinga\Module\Monitoring\Backend;
|
||||
use \Icinga\Module\Monitoring\Form\Command\AcknowledgeForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\CommentForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\CommandForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\CommandWithIdentifierForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\CustomNotificationForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\DelayNotificationForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\RescheduleNextCheckForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\ScheduleDowntimeForm;
|
||||
use \Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm;
|
||||
|
||||
/**
|
||||
* Class Monitoring_CommandController
|
||||
|
|
|
@ -35,12 +35,12 @@ use \Icinga\Web\Controller\BaseConfigController;
|
|||
use \Icinga\Web\Widget\Tab;
|
||||
use \Icinga\Web\Url;
|
||||
|
||||
use \Monitoring\Form\Config\ConfirmRemovalForm;
|
||||
use \Monitoring\Form\Config\Backend\EditBackendForm;
|
||||
use \Monitoring\Form\Config\Backend\CreateBackendForm;
|
||||
use Icinga\Module\Monitoring\Form\Config\ConfirmRemovalForm;
|
||||
use Icinga\Module\Monitoring\Form\Config\Backend\EditBackendForm;
|
||||
use Icinga\Module\Monitoring\Form\Config\Backend\CreateBackendForm;
|
||||
|
||||
use \Monitoring\Form\Config\Instance\EditInstanceForm;
|
||||
use \Monitoring\Form\Config\Instance\CreateInstanceForm;
|
||||
use Icinga\Module\Monitoring\Form\Config\Instance\EditInstanceForm;
|
||||
use Icinga\Module\Monitoring\Form\Config\Instance\CreateInstanceForm;
|
||||
|
||||
/**
|
||||
* Configuration controller for editing monitoring resources
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
|
||||
use \Icinga\Application\Benchmark;
|
||||
use \Icinga\Data\Db\Query;
|
||||
use \Icinga\File\Csv;
|
||||
|
@ -37,7 +36,7 @@ use \Icinga\Web\Widget\Tabextension\BasketAction;
|
|||
use \Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||
use \Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||
use \Icinga\Web\Widget\Tabs;
|
||||
use \Monitoring\Backend;
|
||||
use \Icinga\Module\Monitoring\Backend;
|
||||
|
||||
class Monitoring_ListController extends ActionController
|
||||
{
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Monitoring\Backend;
|
||||
use \Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\Hook;
|
||||
use Monitoring\Object\Host;
|
||||
use Monitoring\Object\Service;
|
||||
use \Icinga\Module\Monitoring\Object\Host;
|
||||
use \Icinga\Module\Monitoring\Object\Service;
|
||||
use Icinga\Application\Benchmark;
|
||||
|
||||
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||
use Icinga\Web\Widget\Tabextension\BasketAction;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Web\Form\Element\DateTimePicker;
|
||||
use \Icinga\Protocol\Commandpipe\Acknowledgement;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Zend_Config;
|
||||
use \Icinga\Web\Form;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Zend_Form_Element_Hidden;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Protocol\Commandpipe\Comment;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Protocol\Commandpipe\CustomNotification;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
/**
|
||||
* Form for the delay notification command
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Zend_Form_Element_Checkbox;
|
||||
use \Icinga\Web\Form\Element\DateTimePicker;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Zend_Form_Element_Text;
|
||||
use \Zend_Validate_GreaterThan;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Exception\ProgrammingError;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Command;
|
||||
namespace Icinga\Module\Monitoring\Form\Command;
|
||||
|
||||
/**
|
||||
* Base class for command forms which allow to propagate the command to child objects too
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
|
||||
namespace Monitoring\Form\Config\Backend;
|
||||
namespace Icinga\Module\Monitoring\Form\Config\Backend;
|
||||
|
||||
use \Zend_Config;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Form\Config\Backend;
|
||||
namespace Icinga\Module\Monitoring\Form\Config\Backend;
|
||||
|
||||
use \Zend_Config;
|
||||
use \Icinga\Web\Form;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
|
||||
namespace Monitoring\Form\Config;
|
||||
namespace Icinga\Module\Monitoring\Form\Config;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
|
||||
namespace Monitoring\Form\Config\Instance;
|
||||
namespace Icinga\Module\Monitoring\Form\Config\Instance;
|
||||
|
||||
use \Icinga\Web\Form;
|
||||
use \Zend_Config;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
|
||||
namespace Monitoring\Form\Config\Instance;
|
||||
namespace Icinga\Module\Monitoring\Form\Config\Instance;
|
||||
|
||||
use \Zend_Config;
|
||||
use \Icinga\Web\Form;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use \Monitoring\Command\Meta;
|
||||
use \Icinga\Module\Monitoring\Command\Meta;
|
||||
|
||||
/**
|
||||
* Class MonitoringCommands
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Monitoring\Plugin\PerfdataSet;
|
||||
use \Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
||||
|
||||
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ There are no matching history entries right now
|
|||
<td><?= $this->escape($event->host_name) ?></td>
|
||||
<? endif ?>
|
||||
|
||||
<? if (! $object instanceof Monitoring\Object\Service): ?>
|
||||
<? if (! $object instanceof Icinga\Module\Monitoring\Object\Service): ?>
|
||||
<td>
|
||||
<? if ($object): ?>
|
||||
<a href="<?= $this->href('monitoring/show/service',array(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Monitoring\Backend;
|
||||
use \Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Util\Format;
|
||||
|
||||
$backend = Backend::getInstance($params->shift('backend'));
|
||||
|
|
|
@ -26,12 +26,11 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring;
|
||||
namespace Icinga\Module\Monitoring;
|
||||
|
||||
use \Exception;
|
||||
use \Icinga\Application\Config as IcingaConfig;
|
||||
use \Icinga\Authentication\Manager as AuthManager;
|
||||
use \Monitoring\Backend\AbstractBackend;
|
||||
|
||||
/**
|
||||
* Container for monitoring backends
|
||||
|
@ -140,7 +139,7 @@ class Backend
|
|||
$config = self::$backendConfigs[$name];
|
||||
$type = $config->type;
|
||||
$type[0] = strtoupper($type[0]);
|
||||
$class = '\\Monitoring\\Backend\\' . $type;
|
||||
$class = '\\Icinga\\Module\\Monitoring\\Backend\\' . $type;
|
||||
self::$instances[$name] = new $class($config);
|
||||
}
|
||||
return self::$instances[$name];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend;
|
||||
namespace Icinga\Module\Monitoring\Backend;
|
||||
|
||||
use Icinga\Data\DatasourceInterface;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
@ -68,7 +68,7 @@ class AbstractBackend implements DatasourceInterface
|
|||
|
||||
protected function tableToClassName($virtual_table)
|
||||
{
|
||||
return 'Monitoring\\View\\'
|
||||
return '\\Icinga\\Module\\Monitoring\\View\\'
|
||||
// . $this->getName()
|
||||
// . '\\'
|
||||
. ucfirst($virtual_table)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend;
|
||||
namespace Icinga\Module\Monitoring\Backend;
|
||||
|
||||
use Icinga\Data\Db\Connection;
|
||||
|
||||
/**
|
||||
* This class provides an easy-to-use interface to the IDO database
|
||||
*
|
||||
* You should usually not directly use this class but go through Monitoring\Backend.
|
||||
* You should usually not directly use this class but go through Icinga\Module\Monitoring\Backend.
|
||||
*
|
||||
* New MySQL indexes:
|
||||
* <code>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Db\Query;
|
||||
use Icinga\Application\Benchmark;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class CommentQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class ContactQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class ContactgroupQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class CustomvarQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class HostgroupQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class HoststatusQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
/**
|
||||
* Notification query
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class ServicegroupQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class ServicestatusQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Ido\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
class StatusQuery extends AbstractQuery
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @package Monitoring
|
||||
*/
|
||||
namespace Monitoring\Backend;
|
||||
namespace Icinga\Module\Monitoring\Backend;
|
||||
|
||||
use Icinga\Protocol\Livestatus\Connection;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Monitoring\Backend\Livestatus\Query;
|
||||
namespace \Icinga\Module\Monitoring\Backend\Livestatus\Query;
|
||||
|
||||
use Icinga\Data\AbstractQuery;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend;
|
||||
namespace Icinga\Module\Monitoring\Backend;
|
||||
|
||||
|
||||
use Icinga\Protocol\Statusdat as StatusdatProtocol;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Criteria;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Criteria;
|
||||
|
||||
/**
|
||||
* Constants for filter definitions.
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Criteria;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Criteria;
|
||||
|
||||
/**
|
||||
* Class Order
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\DataView;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\DataView;
|
||||
|
||||
use Icinga\Protocol\Statusdat\View\ObjectRemappingView;
|
||||
use Icinga\Protocol\Statusdat\IReader;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\DataView;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\DataView;
|
||||
|
||||
use Icinga\Protocol\Statusdat\View\ObjectRemappingView;
|
||||
use Icinga\Protocol\Statusdat\IReader;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\DataView;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\DataView;
|
||||
|
||||
use Icinga\Protocol\Statusdat\View\ObjectRemappingView;
|
||||
use \Icinga\Protocol\Statusdat\IReader;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Query;
|
||||
|
||||
abstract class GroupsummaryQuery extends Query
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Query;
|
||||
|
||||
/**
|
||||
* Class HostgroupsummaryQuery
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Query;
|
||||
|
||||
use Icinga\Protocol\Statusdat;
|
||||
use Icinga\Exception;
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Query;
|
||||
|
||||
use Monitoring\Backend\Statusdat\Criteria\Order;
|
||||
use \Icinga\Module\Monitoring\Backend\Statusdat\Criteria\Order;
|
||||
use Icinga\Protocol\Statusdat;
|
||||
use Icinga\Exception;
|
||||
use Icinga\Data\AbstractQuery;
|
||||
|
@ -48,7 +48,7 @@ abstract class Query extends AbstractQuery
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $viewClass = '\Monitoring\Backend\Statusdat\DataView\StatusdatServiceView';
|
||||
private $viewClass = '\Icinga\Module\Monitoring\Backend\Statusdat\DataView\StatusdatServiceView';
|
||||
private $baseQuery = null;
|
||||
|
||||
public function setBaseQuery(StatusdatQuery $query)
|
||||
|
@ -58,7 +58,7 @@ abstract class Query extends AbstractQuery
|
|||
|
||||
public function setResultViewClass($viewClass)
|
||||
{
|
||||
$this->viewClass = '\Monitoring\Backend\Statusdat\DataView\\'.$viewClass;
|
||||
$this->viewClass = '\Icinga\Module\Monitoring\Backend\Statusdat\DataView\\'.$viewClass;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Query;
|
||||
|
||||
/**
|
||||
* Class ServicegroupsummaryQuery
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Query;
|
||||
|
||||
use Icinga\Protocol\Statusdat;
|
||||
use Icinga\Exception;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
namespace Monitoring\Backend\Statusdat\Query;
|
||||
namespace Icinga\Module\Monitoring\Backend\Statusdat\Query;
|
||||
|
||||
use Icinga\Protocol\Statusdat;
|
||||
use Icinga\Exception;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\Command;
|
||||
namespace Icinga\Module\Monitoring\Command;
|
||||
|
||||
use Icinga\User;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring;
|
||||
namespace Icinga\Module\Monitoring;
|
||||
|
||||
use \Icinga\Application\Config;
|
||||
use Icinga\Web\Session;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Object;
|
||||
namespace Icinga\Module\Monitoring\Object;
|
||||
|
||||
use Icinga\Data\AbstractQuery as Query;
|
||||
use Monitoring\Backend\AbstractBackend;
|
||||
use \Icinga\Module\Monitoring\Backend\AbstractBackend;
|
||||
|
||||
abstract class AbstractObject
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Object;
|
||||
namespace Icinga\Module\Monitoring\Object;
|
||||
|
||||
use Icinga\Data\AbstractQuery as Query;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Object;
|
||||
namespace Icinga\Module\Monitoring\Object;
|
||||
|
||||
use Icinga\Data\AbstractQuery as Query;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring;
|
||||
namespace Icinga\Module\Monitoring;
|
||||
|
||||
require_once ICINGA_LIBDIR . '/Icinga/Application/Cli.php';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Plugin;
|
||||
namespace Icinga\Module\Monitoring\Plugin;
|
||||
|
||||
class Perfdata
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\Plugin;
|
||||
namespace Icinga\Module\Monitoring\Plugin;
|
||||
|
||||
class PerfdataSet
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class CommentView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class ContactView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class ContactgroupView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class CustomvarView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
/**
|
||||
* Class DowntimeView
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class EventHistoryView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class HostgroupView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class HoststatusView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
use Icinga\Data\AbstractQuery;
|
||||
use Icinga\Data\Filter;
|
||||
|
@ -13,11 +13,11 @@ use Icinga\Data\Filter;
|
|||
*
|
||||
* You should not directly instantiate such a view but always go through the
|
||||
* Monitoring Backend. Using the Backend's select() method selecting from
|
||||
* 'virtualtable' returns a Monitoring\View\VirtualtableView instance.
|
||||
* 'virtualtable' returns a Icinga\Module\Monitoring\View\VirtualtableView instance.
|
||||
*
|
||||
* Usage example:
|
||||
* <code>
|
||||
* use Monitoring\Backend;
|
||||
* use \Icinga\Module\Monitoring\Backend;
|
||||
* $backend = Backend::getInstance();
|
||||
* $query = $backend->select()->from('viewname', array(
|
||||
* 'one_column',
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
/**
|
||||
* NotificationView
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class ServicegroupView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Monitoring\View;
|
||||
namespace Icinga\Module\Monitoring\View;
|
||||
|
||||
class StatusView extends MonitoringView
|
||||
{
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../modules/monitoring/application/forms/Command/CommandForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../modules/monitoring/application/forms/Command/AcknowledgeForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Util/ConfigAwareFactory.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Util/DateTimeFactory.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/AcknowledgeForm.php';
|
||||
require_once BaseTestCase::$libDir . '/Util/ConfigAwareFactory.php';
|
||||
require_once BaseTestCase::$libDir . '/Util/DateTimeFactory.php';
|
||||
|
||||
use \DateTimeZone;
|
||||
use \Monitoring\Form\Command\AcknowledgeForm; // Used by constant FORMCLASS
|
||||
use \Icinga\Util\DateTimeFactory;
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
|
||||
class AcknowledgeFormTest extends BaseFormTest
|
||||
class AcknowledgeFormTest extends BaseTestCase
|
||||
{
|
||||
const FORMCLASS = 'Monitoring\Form\Command\AcknowledgeForm';
|
||||
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\AcknowledgeForm';
|
||||
|
||||
/**
|
||||
* Set up the default time zone
|
||||
* Set DateTimeFactory's time zone to UTC
|
||||
*
|
||||
* Utilizes singleton DateTimeFactory
|
||||
*
|
||||
|
@ -29,38 +29,41 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
*/
|
||||
public function setUp()
|
||||
{
|
||||
date_default_timezone_set('UTC');
|
||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||
}
|
||||
|
||||
public function testFormValid()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '0',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '0',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Legal request data without expire time must be considered valid'
|
||||
);
|
||||
|
||||
$formWithExpireTime = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '1',
|
||||
'expiretime' => '10/07/2013 5:32 PM',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$formWithExpireTime = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '1',
|
||||
'expiretime' => '10/07/2013 5:32 PM',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertTrue(
|
||||
$formWithExpireTime->isSubmittedAndValid(),
|
||||
'Legal request data with expire time must be considered valid'
|
||||
|
@ -69,16 +72,18 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
|
||||
public function testFormInvalidWhenCommentMissing()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => '',
|
||||
'persistent' => '0',
|
||||
'expire' => '0',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => '',
|
||||
'persistent' => '0',
|
||||
'expire' => '0',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Missing comment must be considered not valid'
|
||||
|
@ -87,16 +92,18 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
|
||||
public function testFormInvalidWhenExpireTimeMissingAndExpireSet()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '1',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '1',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'If expire is set and expire time is missing, the form must not be valid'
|
||||
|
@ -105,21 +112,22 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
|
||||
public function testFormInvalidWhenExpireTimeIsIncorrectAndExpireSet()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '1',
|
||||
'expiretime' => 'Not a date',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '1',
|
||||
'expiretime' => 'Not a date',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'If expire is set and expire time is incorrect, the form must not be valid'
|
||||
);
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreStop
|
||||
|
|
|
@ -1,29 +1,31 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../modules/monitoring/application/forms/Command/CommentForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use \Monitoring\Form\Command\CommentForm; // Used by constant FORMCLASS
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
class CommentFormTest extends BaseFormTest
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommentForm.php';
|
||||
|
||||
class CommentFormTest extends BaseTestCase
|
||||
{
|
||||
const FORMCLASS = 'Monitoring\Form\Command\CommentForm';
|
||||
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\CommentForm';
|
||||
|
||||
public function testCorrectCommentValidation()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'sticky' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => 'Comment',
|
||||
'sticky' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Legal request data must be considered valid'
|
||||
|
@ -32,14 +34,16 @@ class CommentFormTest extends BaseFormTest
|
|||
|
||||
public function testFormInvalidWhenCommentMissing()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => '',
|
||||
'sticky' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
|
||||
), self::FORMCLASS);
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => '',
|
||||
'sticky' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Missing comment must be considered not valid'
|
||||
|
@ -48,17 +52,18 @@ class CommentFormTest extends BaseFormTest
|
|||
|
||||
public function testFormInvalidWhenAuthorMissing()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => '',
|
||||
'comment' => 'Comment',
|
||||
'sticky' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => '',
|
||||
'comment' => 'Comment',
|
||||
'sticky' => '0',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Missing author must be considered not valid'
|
||||
);
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once __DIR__. '/../../../../../../../library/Icinga/Web/Form.php';
|
||||
require_once __DIR__. '/../../../../../../../library/Icinga/Web/Form/Element/Note.php';
|
||||
require_once __DIR__. '/../../../../../application/forms/Command/CommandForm.php';
|
||||
|
||||
|
||||
use \Zend_View;
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
|
||||
use Monitoring\Form\Command\CommandForm;
|
||||
|
||||
class CommandFormTest extends BaseFormTest
|
||||
{
|
||||
public function testFormCreation()
|
||||
{
|
||||
$view = new Zend_View();
|
||||
$form = new CommandForm();
|
||||
|
||||
$form->setRequest($this->getRequest());
|
||||
|
||||
$form->addNote('444 NOTE 1');
|
||||
$form->addNote('555 NOTE 2');
|
||||
$form->buildForm();
|
||||
$content = $form->render($view);
|
||||
|
||||
$this->assertContains('<dd id="note_0-element">', $content);
|
||||
$this->assertContains('<dd id="note_1-element">', $content);
|
||||
$this->assertContains('444 NOTE 1</dd>', $content);
|
||||
$this->assertContains('555 NOTE 2</dd>', $content);
|
||||
}
|
||||
}
|
|
@ -1,81 +1,63 @@
|
|||
<?php
|
||||
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once __DIR__. '/../../../../../application/forms/Command/CommandForm.php';
|
||||
require_once __DIR__. '/../../../../../application/forms/Command/WithChildrenCommandForm.php';
|
||||
require_once __DIR__. '/../../../../../application/forms/Command/CommandWithIdentifierForm.php';
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use Monitoring\Form\Command\CommandWithIdentifierForm;
|
||||
use \Zend_View;
|
||||
use \Zend_Test_PHPUnit_ControllerTestCase;
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
class CommandWithIdentifierFormTest extends BaseFormTest
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/WithChildrenCommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandWithIdentifierForm.php';
|
||||
|
||||
class CommandWithIdentifierFormTest extends BaseTestCase
|
||||
{
|
||||
const FORMCLASS = "Monitoring\Form\Command\CommandWithIdentifierForm";
|
||||
public function testForm()
|
||||
const FORM_CLASS = '\Icinga\Module\Monitoring\Form\Command\CommandWithIdentifierForm';
|
||||
|
||||
public function testFormInvalidWhenObjectIdMissing()
|
||||
{
|
||||
$form = $this->getRequestForm(array(), self::FORMCLASS);
|
||||
$form->setSubmitLabel('DING DING');
|
||||
$form->buildForm();
|
||||
|
||||
$this->assertCount(4, $form->getElements());
|
||||
}
|
||||
|
||||
public function testCorrectFormValidation()
|
||||
{
|
||||
|
||||
$form = $this->getRequestForm(array(
|
||||
'testval' => 123,
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form->setFieldLabel('Test1');
|
||||
$form->setFieldName('testval');
|
||||
$form->setSubmitLabel('DING DING');
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting correct confirmation with id to be valid"
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'object_id' => '',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidValueValidationErrors()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'testval' => ''
|
||||
), self::FORMCLASS);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting an invalid (empty) value to cause validation errors"
|
||||
'Missing object_id must be considered not valid'
|
||||
);
|
||||
}
|
||||
|
||||
public function testNonNumericValueValidationErrors()
|
||||
public function testFormInvalidWhenObjectIdNonDigit()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'testval' => 'NaN'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'object_id' => 'A Service',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting an non numeric value to cause validation errors"
|
||||
'Non numeric input must be considered not valid'
|
||||
);
|
||||
}
|
||||
|
||||
public function testRequestBridge()
|
||||
public function testFormValidWhenObjectIdIsDigit()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'objectid' => 123123666
|
||||
), self::FORMCLASS);
|
||||
$form->buildForm();
|
||||
|
||||
$this->assertTrue($form->isSubmittedAndValid());
|
||||
|
||||
$this->assertEquals('123123666', $form->getElement('objectid')->getValue());
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'object_id' => 1,
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Digits must be considered valid'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,33 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../application/forms/Command/CustomNotificationForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use \Monitoring\Form\Command\CustomNotificationForm; // Used by constant FORM_CLASS
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
class CustomNotificationFormTest extends BaseFormTest
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CustomNotificationForm.php';
|
||||
|
||||
class CustomNotificationFormTest extends BaseTestCase
|
||||
{
|
||||
const FORM_CLASS = 'Monitoring\Form\Command\CustomNotificationForm';
|
||||
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\CustomNotificationForm';
|
||||
|
||||
public function testFormInvalidWhenCommentMissing()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'Author',
|
||||
'comment' => '',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'author' => 'Author',
|
||||
'comment' => '',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Missing comment must be considered not valid'
|
||||
);
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -1,27 +1,31 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../application/forms/Command/DelayNotificationForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use \Monitoring\Form\Command\DelayNotificationForm; // Used by constant FORM_CLASS
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
class DelayNotificationFormTest extends BaseFormTest
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/DelayNotificationForm.php';
|
||||
|
||||
use Icinga\Module\Monitoring\Form\Command\DelayNotificationForm;
|
||||
|
||||
class DelayNotificationFormTest extends BaseTestCase
|
||||
{
|
||||
const FORM_CLASS = 'Monitoring\Form\Command\DelayNotificationForm';
|
||||
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\DelayNotificationForm';
|
||||
|
||||
public function testFormInvalidWhenNotificationDelayMissing()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'minutes' => '',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'minutes' => '',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Missing notification delay must be considered invalid'
|
||||
|
@ -30,11 +34,13 @@ class DelayNotificationFormTest extends BaseFormTest
|
|||
|
||||
public function testFormInvalidWhenNotificationDelayNaN()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'minutes' => 'A String',
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'minutes' => 'A String',
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Incorrect notification delay, i.e. NaN must be considered invalid'
|
||||
|
@ -43,15 +49,16 @@ class DelayNotificationFormTest extends BaseFormTest
|
|||
|
||||
public function testFormInvalidWhenNotificationDelayOverflows()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'minutes' => DelayNotificationForm::MAX_DELAY + 1,
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'minutes' => DelayNotificationForm::MAX_DELAY + 1,
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Notification delay bigger than constant "DelayNotificationForm::MAX_DELAY" must be considered invalid'
|
||||
);
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../application/forms/Command/RescheduleNextCheckForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Util/ConfigAwareFactory.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Util/DateTimeFactory.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/WithChildrenCommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/RescheduleNextCheckForm.php';
|
||||
require_once BaseTestCase::$libDir . '/Util/ConfigAwareFactory.php';
|
||||
require_once BaseTestCase::$libDir . '/Util/DateTimeFactory.php';
|
||||
|
||||
use \Monitoring\Form\Command\RescheduleNextCheckForm; // Used by constant FORM_CLASS
|
||||
use \DateTimeZone;
|
||||
use \Icinga\Util\DateTimeFactory;
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
|
||||
class RescheduleNextCheckFormTest extends BaseFormTest
|
||||
class RescheduleNextCheckFormTest extends BaseTestCase
|
||||
{
|
||||
const FORM_CLASS = 'Monitoring\Form\Command\RescheduleNextCheckForm';
|
||||
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\RescheduleNextCheckForm';
|
||||
|
||||
/**
|
||||
* Set up the default time zone
|
||||
* Set DateTimeFactory's time zone to UTC
|
||||
*
|
||||
* Utilizes singleton DateTimeFactory
|
||||
*
|
||||
|
@ -28,44 +30,48 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
|||
*/
|
||||
public function setUp()
|
||||
{
|
||||
date_default_timezone_set('UTC');
|
||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||
}
|
||||
|
||||
public function testFormInvalidWhenChecktimeIsIncorrect()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'checktime' => '2013-24-12 17:30:00',
|
||||
'forcecheck' => 0,
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'checktime' => '2013-24-12 17:30:00',
|
||||
'forcecheck' => 0,
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting a logically incorrect checktime as invalid'
|
||||
);
|
||||
|
||||
$form2 = $this->getRequestForm(array(
|
||||
'checktime' => 'Captain Morgan',
|
||||
'forcecheck' => 1,
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form2 = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'checktime' => 'Captain Morgan',
|
||||
'forcecheck' => 1,
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form2->isSubmittedAndValid(),
|
||||
'Providing arbitrary strings as checktime must be considered invalid'
|
||||
);
|
||||
|
||||
$form3 = $this->getRequestForm(array(
|
||||
'checktime' => '',
|
||||
'forcecheck' => 0,
|
||||
'btn_submit' => 'Submit'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form3 = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'checktime' => '',
|
||||
'forcecheck' => 0,
|
||||
'btn_submit' => 'Submit'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
$form3->isSubmittedAndValid(),
|
||||
'Missing checktime must be considered invalid'
|
||||
);
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreStop
|
||||
|
|
|
@ -1,334 +0,0 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Util/ConfigAwareFactory.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Util/DateTimeFactory.php');
|
||||
|
||||
use \Monitoring\Form\Command\ScheduleDowntimeForm; // Used by constant FORM_CLASS
|
||||
use \DateTimeZone;
|
||||
use \Icinga\Util\DateTimeFactory;
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
|
||||
class ScheduleDowntimeFormTest extends BaseFormTest
|
||||
{
|
||||
const FORM_CLASS = 'Monitoring\Form\Command\ScheduleDowntimeForm';
|
||||
|
||||
/**
|
||||
* Set up the default time zone
|
||||
*
|
||||
* Utilizes singleton DateTimeFactory
|
||||
*
|
||||
* @backupStaticAttributes enabled
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
date_default_timezone_set('UTC');
|
||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||
}
|
||||
|
||||
public function testCorrectFormElementCreation()
|
||||
{
|
||||
$formFixed = $this->getRequestForm(array(), self::FORM_CLASS);
|
||||
$formFixed->buildForm();
|
||||
$formFlexible = $this->getRequestForm(array(
|
||||
'type' => 'flexible'
|
||||
), self::FORM_CLASS);
|
||||
$formFlexible->buildForm();
|
||||
|
||||
$form = $this->getRequestForm(array(), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
$form->buildForm();
|
||||
}
|
||||
|
||||
public function testCorrectValidationWithChildrend()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'btn_submit' => 'foo',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting a correct fixed downtime form to be considered valid'
|
||||
);
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
||||
'hours' => '10',
|
||||
'minutes' => '10',
|
||||
'btn_submit' => 'foo'
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting a correct flexible downtime form to be considered valid'
|
||||
);
|
||||
}
|
||||
|
||||
public function testMissingFlexibleDurationRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert missing hours and minutes in downtime form to cause failing validation'
|
||||
);
|
||||
}
|
||||
|
||||
public function testMissingAuthorRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => '',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert missing author to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
||||
public function testMissingCommentRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'OK',
|
||||
'comment' => '',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert missing comment to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidTriggeredFieldValueRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'OK',
|
||||
'comment' => 'OK',
|
||||
'triggered' => 'HAHA',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert invalid trigger field to cause validation to fail'
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidStartTimeRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'OK',
|
||||
'comment' => 'OK',
|
||||
'triggered' => '123',
|
||||
'starttime' => '17/07/2013',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert incorrect start time to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidEndTimeRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'OK',
|
||||
'comment' => 'OK',
|
||||
'triggered' => '123',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => 'DING',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert invalid endtime to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function testInvalidHoursValueRecognitionInFlexibleDowntime()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'OK',
|
||||
'comment' => 'OK',
|
||||
'triggered' => '123',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
||||
'hours' => '-1',
|
||||
'minutes' => '12',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert negative hours to cause validation errors in flexible downtime'
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidMinutesValueRecognitionInFlexibleDowntime()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'OK',
|
||||
'comment' => 'OK',
|
||||
'triggered' => '123',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
||||
'hours' => '12',
|
||||
'minutes' => 'DING',
|
||||
// 'childobjects' => '',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert non numeric valud to cause validation errors in flexible downtime '
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function testCorrectScheduleDowntimeWithoutChildrenForm()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'btn_submit' => 'foo',
|
||||
'childobjects' => '0',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(false);
|
||||
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert a correct schedule downtime without children form to be considered valid'
|
||||
);
|
||||
}
|
||||
|
||||
public function testIncorrectChildObjectsRecognition() {
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'childobjects' => 'AHA',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(false);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert and incorrect (non-numeric) childobjects value to cause validation errors'
|
||||
);
|
||||
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '17/07/2013 10:30 AM',
|
||||
'endtime' => '18/07/2013 10:30 AM',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'childobjects' => '4',
|
||||
), self::FORM_CLASS);
|
||||
$form->setWithChildren(false);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert and incorrect (numeric) childobjects value to cause validation errors'
|
||||
);
|
||||
}
|
||||
|
||||
public function testTimeRange()
|
||||
{
|
||||
$form = $this->getRequestForm(array(), self::FORM_CLASS);
|
||||
$form->buildForm();
|
||||
|
||||
$time1 = $form->getElement('starttime')->getValue();
|
||||
$time2 = $form->getElement('endtime')->getValue();
|
||||
|
||||
$this->assertEquals(3600, ($time2 - $time1));
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreStop
|
|
@ -1,68 +1,87 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Test\Monitoring\Forms\Command;
|
||||
|
||||
require_once realpath('library/Icinga/Web/Form/BaseFormTest.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../application/forms/Command/SubmitPassiveCheckResultForm.php');
|
||||
require_once realpath(__DIR__ . '/../../../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use \Monitoring\Form\Command\SubmitPassiveCheckResultForm; // Used by constant FORM_CLASS
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
||||
require_once BaseTestCase::$libDir . '/Exception/ProgrammingError.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/CommandForm.php';
|
||||
require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php';
|
||||
|
||||
use Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm;
|
||||
|
||||
class SubmitPassiveCheckResultFormTest extends BaseTestCase
|
||||
{
|
||||
const FORM_CLASS = 'Monitoring\Form\Command\SubmitPassiveCheckResultForm';
|
||||
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm';
|
||||
|
||||
public function testStateTypes()
|
||||
{
|
||||
$form = $this->getRequestForm(array(), self::FORM_CLASS);
|
||||
$form = $this->createForm(self::FORM_CLASS, array());
|
||||
|
||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
$options = $form->getOptions();
|
||||
$this->assertCount(4, $options, 'Assert correct number of states in service passive checks form');
|
||||
$this->assertEquals('OK', $options[0], 'Assert OK state to be available in service passive check form');
|
||||
$this->assertEquals('WARNING', $options[1], 'Assert WARNING state to be available in service passive check form');
|
||||
$this->assertEquals('CRITICAL', $options[2], 'Assert CRITICAL state to be available in service passive check form');
|
||||
$this->assertEquals('UNKNOWN', $options[3], 'Assert UNKNOWN state to be available in service passive check form');
|
||||
|
||||
$this->assertEquals(
|
||||
'WARNING',
|
||||
$options[1],
|
||||
'Assert WARNING state to be available in service passive check form'
|
||||
);
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
$options[2],
|
||||
'Assert CRITICAL state to be available in service passive check form'
|
||||
);
|
||||
$this->assertEquals(
|
||||
'UNKNOWN',
|
||||
$options[3],
|
||||
'Assert UNKNOWN state to be available in service passive check form'
|
||||
);
|
||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_HOST);
|
||||
$options = $form->getOptions();
|
||||
$this->assertCount(3, $options, 'Assert correct number of states in host passive checks form');
|
||||
$this->assertEquals('UP', $options[0], 'Assert UP state to be available in host passive check form');
|
||||
$this->assertEquals('DOWN', $options[1], 'Assert DOWN state to be available in host passive check form');
|
||||
$this->assertEquals('UNREACHABLE', $options[2], 'Assert UNREACHABLE state to be available in host passive check form');
|
||||
$this->assertEquals(
|
||||
'UNREACHABLE',
|
||||
$options[2],
|
||||
'Assert UNREACHABLE state to be available in host passive check form'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Icinga\Exception\ProgrammingError
|
||||
* @expectedExceptionMessage Type is not valid
|
||||
* @expectedException Icinga\Exception\ProgrammingError
|
||||
* @expectedExceptionMessage Type is not valid
|
||||
*/
|
||||
public function testMissingTypeThrowingException()
|
||||
{
|
||||
$form = $this->getRequestForm(array(), self::FORM_CLASS);
|
||||
$form = $this->createForm(self::FORM_CLASS, array());
|
||||
$form->buildForm();
|
||||
}
|
||||
|
||||
public function testCorrectFormCreation()
|
||||
{
|
||||
$form = $this->getRequestForm(array(), self::FORM_CLASS);
|
||||
$form = $this->createForm(self::FORM_CLASS, array());
|
||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
$form->buildForm();
|
||||
}
|
||||
|
||||
public function testCorrectServicePassiveCheckSubmission()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'pluginstate' => 0,
|
||||
'checkoutput' => 'DING',
|
||||
'performancedata' => '',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORM_CLASS);
|
||||
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'pluginstate' => 0,
|
||||
'checkoutput' => 'DING',
|
||||
'performancedata' => '',
|
||||
'btn_submit' => 'foo'
|
||||
)
|
||||
);
|
||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert a correct passive service check form to pass form validation'
|
||||
|
@ -71,13 +90,15 @@ class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
|||
|
||||
public function testIncorrectCheckoutputRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'pluginstate' => 0,
|
||||
'checkoutput' => '',
|
||||
'performancedata' => ''
|
||||
), self::FORM_CLASS);
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'pluginstate' => 0,
|
||||
'checkoutput' => '',
|
||||
'performancedata' => ''
|
||||
)
|
||||
);
|
||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert empty checkoutput to cause validation errors in passive service check '
|
||||
|
@ -86,13 +107,15 @@ class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
|||
|
||||
public function testIncorrectStateRecognition()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'pluginstate' => 'LA',
|
||||
'checkoutput' => 'DING',
|
||||
'performancedata' => ''
|
||||
), self::FORM_CLASS);
|
||||
$form = $this->createForm(
|
||||
self::FORM_CLASS,
|
||||
array(
|
||||
'pluginstate' => 'LA',
|
||||
'checkoutput' => 'DING',
|
||||
'performancedata' => ''
|
||||
)
|
||||
);
|
||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert invalid (non-numeric) state to cause validation errors in passive service check'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Test\Modules\Monitoring\Application\Views\Helpers;
|
||||
|
||||
use Monitoring\Command\Meta;
|
||||
use \Icinga\Module\Monitoring\Command\Meta;
|
||||
|
||||
require_once 'Zend/View/Helper/Abstract.php';
|
||||
require_once 'Zend/View.php';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Tests\Monitoring\Backend\Statusdat;
|
||||
use Tests\Icinga\Protocol\Statusdat\ReaderMock as ReaderMock;
|
||||
use Monitoring\Backend\Statusdat\Query\ServicegroupsummaryQuery;
|
||||
use \Icinga\Module\Monitoring\Backend\Statusdat\Query\ServicegroupsummaryQuery;
|
||||
use Tests\Icinga\Protocol\Statusdat\StatusdatTestLoader;
|
||||
|
||||
$base = dirname(__FILE__)."/../../../../..";
|
||||
|
@ -12,7 +12,7 @@ StatusdatTestLoader::requireLibrary();
|
|||
require_once(realpath($base."/library/Monitoring/Backend/Statusdat/Query/GroupsummaryQuery.php"));
|
||||
require_once(realpath($base."/library/Monitoring/Backend/Statusdat/Query/ServicegroupsummaryQuery.php"));
|
||||
|
||||
class BackendMock extends \Monitoring\Backend\AbstractBackend
|
||||
class BackendMock extends \Icinga\Module\Monitoring\Backend\AbstractBackend
|
||||
{
|
||||
public $reader;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Test\Modules\Monitoring\Library\Command;
|
|||
require_once __DIR__. '/../../../../library/Monitoring/Command/Meta.php';
|
||||
require_once __DIR__. '/../../../../../../library/Icinga/Exception/ProgrammingError.php';
|
||||
|
||||
use Monitoring\Command\Meta;
|
||||
use \Icinga\Module\Monitoring\Command\Meta;
|
||||
|
||||
class HostStruct extends \stdClass
|
||||
{
|
||||
|
|
|
@ -40,8 +40,8 @@ use \Zend_Test_PHPUnit_ControllerTestCase;
|
|||
use \Icinga\Protocol\Statusdat\Reader;
|
||||
use \Icinga\Web\Controller\ActionController;
|
||||
use \Icinga\Application\DbAdapterFactory;
|
||||
use \Monitoring\Backend\Ido;
|
||||
use \Monitoring\Backend\Statusdat;
|
||||
use \Icinga\Module\Monitoring\Backend\Ido;
|
||||
use \Icinga\Module\Monitoring\Backend\Statusdat;
|
||||
use \Test\Monitoring\Testlib\DataSource\TestFixture;
|
||||
use \Test\Monitoring\Testlib\DataSource\DataSourceTestSetup;
|
||||
|
||||
|
@ -262,4 +262,4 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ require_once BaseTestCase::$libDir . '/Web/Url.php';
|
|||
require_once BaseTestCase::$appDir . '/forms/Config/Authentication/BaseBackendForm.php';
|
||||
require_once BaseTestCase::$appDir . '/forms/Config/Authentication/DbBackendForm.php';
|
||||
require_once BaseTestCase::$appDir . '/forms/Config/Authentication/LdapBackendForm.php';
|
||||
require_once BaseTestCase::$appDir . '/forms/Config/Authentication/ReorderForm.php';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
use \Zend_Config;
|
||||
|
|
|
@ -2,24 +2,24 @@
|
|||
// {{{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>
|
||||
|
@ -227,4 +227,4 @@ class GeneralFormTest extends BaseTestCase
|
|||
"Asserting the db resource to be displayed when db preference is set"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ require_once 'Zend/Config.php';
|
|||
require_once 'Zend/Config/Ini.php';
|
||||
require_once BaseTestCase::$libDir . '/Web/Form.php';
|
||||
require_once BaseTestCase::$appDir . '/forms/Config/GeneralForm.php';
|
||||
require_once BaseTestCase::$appDir . '/forms/Config/LoggingForm.php';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
use \Zend_Config;
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga 2 Web.
|
||||
*
|
||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Tests\Icinga\Test;
|
||||
|
||||
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');
|
||||
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
||||
class BaseTestCaseFormTest extends BaseTestCase
|
||||
{
|
||||
public function testFormCreation()
|
||||
{
|
||||
$form1 = $this->createForm('Icinga\Form\Authentication\LoginForm');
|
||||
$this->assertInstanceOf('Icinga\Web\Form', $form1);
|
||||
$form2 = $this->createForm('Monitoring\Form\Config\ConfirmRemovalForm');
|
||||
$this->assertInstanceOf('Icinga\Web\Form', $form2);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue