From 03f081ce33b41f528c39b35cfbbfaa7fc6677f4b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Aug 2013 15:04:50 +0200 Subject: [PATCH 01/10] Module/Autoloader: Register Icinga\Module\ namespace refs #4586 --- library/Icinga/Application/Modules/Module.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 86f0546e7..1bc88c84b 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -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()); } } From c86874d4ba6093c390a2670de9f727acebd78d9d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Aug 2013 15:32:25 +0200 Subject: [PATCH 02/10] =?UTF-8?q?Rename=20namespace=20Monitoring=20to=20Ic?= =?UTF-8?q?ing=C3=A6\Module\Monitoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #4586 --- .../controllers/CommandController.php | 20 +++++++++---------- .../controllers/ListController.php | 3 +-- .../controllers/ShowController.php | 7 +++---- .../forms/Command/AcknowledgeForm.php | 2 +- .../application/forms/Command/CommandForm.php | 2 +- .../Command/CommandWithIdentifierForm.php | 2 +- .../application/forms/Command/CommentForm.php | 2 +- .../forms/Command/CustomNotificationForm.php | 2 +- .../forms/Command/DelayNotificationForm.php | 2 +- .../forms/Command/RescheduleNextCheckForm.php | 2 +- .../forms/Command/ScheduleDowntimeForm.php | 2 +- .../Command/SubmitPassiveCheckResultForm.php | 2 +- .../forms/Command/WithChildrenCommandForm.php | 2 +- .../views/helpers/MonitoringCommands.php | 2 +- .../application/views/helpers/Perfdata.php | 2 +- modules/monitoring/bin/action/list.inc.php | 2 +- .../monitoring/library/Monitoring/Backend.php | 5 ++--- .../Monitoring/Backend/AbstractBackend.php | 4 ++-- .../library/Monitoring/Backend/Ido.php | 2 +- .../Backend/Ido/Query/AbstractQuery.php | 2 +- .../Backend/Ido/Query/CommentQuery.php | 2 +- .../Backend/Ido/Query/ContactQuery.php | 2 +- .../Backend/Ido/Query/ContactgroupQuery.php | 2 +- .../Backend/Ido/Query/CustomvarQuery.php | 2 +- .../Backend/Ido/Query/DowntimeQuery.php | 2 +- .../Backend/Ido/Query/EventHistoryQuery.php | 2 +- .../Backend/Ido/Query/HostgroupQuery.php | 2 +- .../Backend/Ido/Query/HoststatusQuery.php | 2 +- .../Backend/Ido/Query/NotificationQuery.php | 2 +- .../Backend/Ido/Query/ServicegroupQuery.php | 2 +- .../Backend/Ido/Query/ServicestatusQuery.php | 2 +- .../Backend/Ido/Query/StatusQuery.php | 2 +- .../library/Monitoring/Backend/Livestatus.php | 2 +- .../Backend/Livestatus/Query/StatusQuery.php | 2 +- .../library/Monitoring/Backend/Statusdat.php | 2 +- .../Backend/Statusdat/Criteria/Filter.php | 2 +- .../Backend/Statusdat/Criteria/Order.php | 2 +- .../Statusdat/DataView/HostStatusView.php | 2 +- .../Statusdat/DataView/ServiceStatusView.php | 2 +- .../DataView/StatusdatServiceView.php | 2 +- .../Statusdat/Query/GroupsummaryQuery.php | 2 +- .../Statusdat/Query/HostgroupsummaryQuery.php | 2 +- .../Backend/Statusdat/Query/HostlistQuery.php | 2 +- .../Backend/Statusdat/Query/Query.php | 4 ++-- .../Query/ServicegroupsummaryQuery.php | 2 +- .../Statusdat/Query/ServicelistQuery.php | 2 +- .../Backend/Statusdat/Query/StatusQuery.php | 2 +- .../library/Monitoring/Command/Meta.php | 2 +- .../library/Monitoring/Environment.php | 2 +- .../Monitoring/Object/AbstractObject.php | 4 ++-- .../library/Monitoring/Object/Host.php | 2 +- .../library/Monitoring/Object/Service.php | 2 +- .../monitoring/library/Monitoring/Plugin.php | 2 +- .../library/Monitoring/Plugin/Perfdata.php | 2 +- .../library/Monitoring/Plugin/PerfdataSet.php | 2 +- .../library/Monitoring/View/CommentView.php | 2 +- .../library/Monitoring/View/ContactView.php | 2 +- .../Monitoring/View/ContactgroupView.php | 2 +- .../library/Monitoring/View/CustomvarView.php | 2 +- .../library/Monitoring/View/DowntimeView.php | 2 +- .../Monitoring/View/EventHistoryView.php | 2 +- .../library/Monitoring/View/HostgroupView.php | 2 +- .../Monitoring/View/HoststatusView.php | 2 +- .../Monitoring/View/MonitoringView.php | 4 ++-- .../Monitoring/View/NotificationView.php | 2 +- .../Monitoring/View/ServicegroupView.php | 2 +- .../library/Monitoring/View/StatusView.php | 2 +- .../forms/Command/AcknowledgeFormTest.php | 2 +- .../forms/Command/CommentFormTest.php | 2 +- .../forms/Command/ConfirmationFormTest.php | 3 +-- .../ConfirmationWithIdentifierFormTest.php | 2 +- .../Command/CustomNotificationFormTest.php | 2 +- .../Command/DelayNotificationFormTest.php | 2 +- .../Command/RescheduleNextCheckFormTest.php | 2 +- .../Command/ScheduleDowntimeFormTest.php | 2 +- .../Command/SubmitPassiveCheckResultTest.php | 2 +- .../views/helpers/MonitoringCommandsTest.php | 2 +- .../ServicegroupsummaryQueryTest.php | 4 ++-- .../test/php/library/Command/MetaTest.php | 2 +- .../php/testlib/MonitoringControllerTest.php | 6 +++--- .../Paginator/Adapter/QueryAdapterTest.php | 2 +- .../ScrollingStyle/SlidingWithBorderTest.php | 2 +- 82 files changed, 101 insertions(+), 105 deletions(-) diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index 2b3d05afa..ce1dad859 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -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 diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b17412a9e..fc6c3c45e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -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 { diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 41187f832..059e76935 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -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; diff --git a/modules/monitoring/application/forms/Command/AcknowledgeForm.php b/modules/monitoring/application/forms/Command/AcknowledgeForm.php index c671046a6..00b35343b 100644 --- a/modules/monitoring/application/forms/Command/AcknowledgeForm.php +++ b/modules/monitoring/application/forms/Command/AcknowledgeForm.php @@ -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; diff --git a/modules/monitoring/application/forms/Command/CommandForm.php b/modules/monitoring/application/forms/Command/CommandForm.php index 04ef1150e..32bac99ce 100644 --- a/modules/monitoring/application/forms/Command/CommandForm.php +++ b/modules/monitoring/application/forms/Command/CommandForm.php @@ -26,7 +26,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Command; +namespace Icinga\Module\Monitoring\Form\Command; use \Zend_Config; use \Icinga\Web\Form; diff --git a/modules/monitoring/application/forms/Command/CommandWithIdentifierForm.php b/modules/monitoring/application/forms/Command/CommandWithIdentifierForm.php index c59b737d3..cfc0bfaff 100644 --- a/modules/monitoring/application/forms/Command/CommandWithIdentifierForm.php +++ b/modules/monitoring/application/forms/Command/CommandWithIdentifierForm.php @@ -26,7 +26,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Command; +namespace Icinga\Module\Monitoring\Form\Command; use \Zend_Form_Element_Hidden; diff --git a/modules/monitoring/application/forms/Command/CommentForm.php b/modules/monitoring/application/forms/Command/CommentForm.php index 28f79f444..a9175d1cb 100644 --- a/modules/monitoring/application/forms/Command/CommentForm.php +++ b/modules/monitoring/application/forms/Command/CommentForm.php @@ -26,7 +26,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Command; +namespace Icinga\Module\Monitoring\Form\Command; use \Icinga\Protocol\Commandpipe\Comment; diff --git a/modules/monitoring/application/forms/Command/CustomNotificationForm.php b/modules/monitoring/application/forms/Command/CustomNotificationForm.php index c4c5fbfd9..1e07220d7 100644 --- a/modules/monitoring/application/forms/Command/CustomNotificationForm.php +++ b/modules/monitoring/application/forms/Command/CustomNotificationForm.php @@ -26,7 +26,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Command; +namespace Icinga\Module\Monitoring\Form\Command; use \Icinga\Protocol\Commandpipe\CustomNotification; diff --git a/modules/monitoring/application/forms/Command/DelayNotificationForm.php b/modules/monitoring/application/forms/Command/DelayNotificationForm.php index acf15b445..34bda250e 100644 --- a/modules/monitoring/application/forms/Command/DelayNotificationForm.php +++ b/modules/monitoring/application/forms/Command/DelayNotificationForm.php @@ -26,7 +26,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Command; +namespace Icinga\Module\Monitoring\Form\Command; /** * Form for the delay notification command diff --git a/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php b/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php index a1b7f11dc..0aa18e903 100644 --- a/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php +++ b/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php @@ -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; diff --git a/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php b/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php index 5eb13f62b..2944aef21 100644 --- a/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php +++ b/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php @@ -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; diff --git a/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php b/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php index e70c18ec0..54471e4b3 100644 --- a/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php +++ b/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php @@ -26,7 +26,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Command; +namespace Icinga\Module\Monitoring\Form\Command; use \Icinga\Exception\ProgrammingError; diff --git a/modules/monitoring/application/forms/Command/WithChildrenCommandForm.php b/modules/monitoring/application/forms/Command/WithChildrenCommandForm.php index 4a6c6360c..ff5a4df62 100644 --- a/modules/monitoring/application/forms/Command/WithChildrenCommandForm.php +++ b/modules/monitoring/application/forms/Command/WithChildrenCommandForm.php @@ -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 diff --git a/modules/monitoring/application/views/helpers/MonitoringCommands.php b/modules/monitoring/application/views/helpers/MonitoringCommands.php index 0c35460b9..abd9588ef 100644 --- a/modules/monitoring/application/views/helpers/MonitoringCommands.php +++ b/modules/monitoring/application/views/helpers/MonitoringCommands.php @@ -23,7 +23,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -use \Monitoring\Command\Meta; +use \Icinga\Module\Monitoring\Command\Meta; /** * Class MonitoringCommands diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 2b7e938a6..3668f86ad 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -1,6 +1,6 @@ shift('backend')); diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php index f5afce884..54579c09d 100644 --- a/modules/monitoring/library/Monitoring/Backend.php +++ b/modules/monitoring/library/Monitoring/Backend.php @@ -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]; diff --git a/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php b/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php index 1c38fd2f8..581e0ac89 100644 --- a/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/AbstractBackend.php @@ -1,6 +1,6 @@ getName() // . '\\' . ucfirst($virtual_table) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido.php b/modules/monitoring/library/Monitoring/Backend/Ido.php index 9af41fdd5..2290855cf 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido.php @@ -1,6 +1,6 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\View; +namespace Icinga\Module\Monitoring\View; /** * Class DowntimeView diff --git a/modules/monitoring/library/Monitoring/View/EventHistoryView.php b/modules/monitoring/library/Monitoring/View/EventHistoryView.php index 16a90158d..0feac0e17 100644 --- a/modules/monitoring/library/Monitoring/View/EventHistoryView.php +++ b/modules/monitoring/library/Monitoring/View/EventHistoryView.php @@ -1,6 +1,6 @@ - * use Monitoring\Backend; + * use \Icinga\Module\Monitoring\Backend; * $backend = Backend::getInstance(); * $query = $backend->select()->from('viewname', array( * 'one_column', diff --git a/modules/monitoring/library/Monitoring/View/NotificationView.php b/modules/monitoring/library/Monitoring/View/NotificationView.php index bad01cbde..b0372f6a9 100644 --- a/modules/monitoring/library/Monitoring/View/NotificationView.php +++ b/modules/monitoring/library/Monitoring/View/NotificationView.php @@ -23,7 +23,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\View; +namespace Icinga\Module\Monitoring\View; /** * NotificationView diff --git a/modules/monitoring/library/Monitoring/View/ServicegroupView.php b/modules/monitoring/library/Monitoring/View/ServicegroupView.php index da872a6c7..73fd1efa7 100644 --- a/modules/monitoring/library/Monitoring/View/ServicegroupView.php +++ b/modules/monitoring/library/Monitoring/View/ServicegroupView.php @@ -1,6 +1,6 @@ Date: Tue, 20 Aug 2013 15:46:53 +0200 Subject: [PATCH 03/10] Fix tests after renaming the namespace refs #4586 --- .../library/Monitoring/Backend/Statusdat/Query/Query.php | 4 ++-- .../php/application/forms/Command/AcknowledgeFormTest.php | 2 +- .../test/php/application/forms/Command/CommentFormTest.php | 2 +- .../forms/Command/ConfirmationWithIdentifierFormTest.php | 2 +- .../application/forms/Command/CustomNotificationFormTest.php | 2 +- .../application/forms/Command/DelayNotificationFormTest.php | 2 +- .../application/forms/Command/RescheduleNextCheckFormTest.php | 2 +- .../application/forms/Command/ScheduleDowntimeFormTest.php | 2 +- .../forms/Command/SubmitPassiveCheckResultTest.php | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php b/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php index 9cadb6827..4c4d54c7c 100644 --- a/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php +++ b/modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php @@ -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; } diff --git a/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php b/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php index 415beae40..f89ce5169 100644 --- a/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php @@ -18,7 +18,7 @@ use \Test\Icinga\Web\Form\BaseFormTest; class AcknowledgeFormTest extends BaseFormTest { - const FORMCLASS = 'Monitoring\Form\Command\AcknowledgeForm'; + const FORMCLASS = '\Icinga\Module\Monitoring\Form\Command\AcknowledgeForm'; /** * Set up the default time zone diff --git a/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php b/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php index 2dd1f5793..2485b7c59 100644 --- a/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php @@ -13,7 +13,7 @@ use \Test\Icinga\Web\Form\BaseFormTest; class CommentFormTest extends BaseFormTest { - const FORMCLASS = 'Monitoring\Form\Command\CommentForm'; + const FORMCLASS = '\Icinga\Module\Monitoring\Form\Command\CommentForm'; public function testCorrectCommentValidation() { diff --git a/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php b/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php index 618d094ac..7c3436395 100644 --- a/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php @@ -15,7 +15,7 @@ use \Test\Icinga\Web\Form\BaseFormTest; class CommandWithIdentifierFormTest extends BaseFormTest { - const FORMCLASS = "Monitoring\Form\Command\CommandWithIdentifierForm"; + const FORMCLASS = "\Icinga\Module\Monitoring\Form\Command\CommandWithIdentifierForm"; public function testForm() { $form = $this->getRequestForm(array(), self::FORMCLASS); diff --git a/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php b/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php index c26ef4f8e..39a3e72d6 100644 --- a/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php @@ -13,7 +13,7 @@ use \Icinga\Module\Monitoring\Form\Command\CustomNotificationForm; // Used by co class CustomNotificationFormTest extends BaseFormTest { - const FORM_CLASS = 'Monitoring\Form\Command\CustomNotificationForm'; + const FORM_CLASS = '\Icinga\Module\Monitoring\Form\Command\CustomNotificationForm'; public function testFormInvalidWhenCommentMissing() { diff --git a/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php b/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php index 51900f7ab..25e8a757d 100644 --- a/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php @@ -13,7 +13,7 @@ use \Icinga\Module\Monitoring\Form\Command\DelayNotificationForm; // Used by con class DelayNotificationFormTest extends BaseFormTest { - const FORM_CLASS = 'Monitoring\Form\Command\DelayNotificationForm'; + const FORM_CLASS = '\Icinga\Module\Monitoring\Form\Command\DelayNotificationForm'; public function testFormInvalidWhenNotificationDelayMissing() { diff --git a/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php b/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php index bfbc191fc..5d90c6eda 100644 --- a/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php @@ -17,7 +17,7 @@ use \Test\Icinga\Web\Form\BaseFormTest; class RescheduleNextCheckFormTest extends BaseFormTest { - const FORM_CLASS = 'Monitoring\Form\Command\RescheduleNextCheckForm'; + const FORM_CLASS = '\Icinga\Module\Monitoring\Form\Command\RescheduleNextCheckForm'; /** * Set up the default time zone diff --git a/modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php b/modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php index 5f2282916..b17f05a30 100644 --- a/modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php @@ -17,7 +17,7 @@ use \Test\Icinga\Web\Form\BaseFormTest; class ScheduleDowntimeFormTest extends BaseFormTest { - const FORM_CLASS = 'Monitoring\Form\Command\ScheduleDowntimeForm'; + const FORM_CLASS = '\Icinga\Module\Monitoring\Form\Command\ScheduleDowntimeForm'; /** * Set up the default time zone diff --git a/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php b/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php index 4c027065e..085d8120b 100644 --- a/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php +++ b/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php @@ -13,7 +13,7 @@ use \Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm; // Used class SubmitPassiveCheckResultFormTest extends BaseFormTest { - const FORM_CLASS = 'Monitoring\Form\Command\SubmitPassiveCheckResultForm'; + const FORM_CLASS = '\Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm'; public function testStateTypes() { From 092c5780ea37000cc91943f9e8aef31dd018ae14 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Sep 2013 17:33:12 +0200 Subject: [PATCH 04/10] CS: Fix violations for overdue files refs #4586 --- .../Config/Authentication/DbBackendForm.php | 14 ++++++----- library/Icinga/Protocol/Statusdat/Query.php | 2 +- library/Icinga/Protocol/Statusdat/Reader.php | 6 ++--- .../Statusdat/View/MonitoringObjectList.php | 24 ++++++++++++------- .../Statusdat/View/ObjectRemappingView.php | 3 ++- library/Icinga/Util/Format.php | 8 +++++-- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index c49205161..658e7c3d1 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -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; diff --git a/library/Icinga/Protocol/Statusdat/Query.php b/library/Icinga/Protocol/Statusdat/Query.php index 90c34486c..fa913ff5d 100755 --- a/library/Icinga/Protocol/Statusdat/Query.php +++ b/library/Icinga/Protocol/Statusdat/Query.php @@ -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; } - } diff --git a/library/Icinga/Protocol/Statusdat/Reader.php b/library/Icinga/Protocol/Statusdat/Reader.php index c079c0048..4a266e131 100755 --- a/library/Icinga/Protocol/Statusdat/Reader.php +++ b/library/Icinga/Protocol/Statusdat/Reader.php @@ -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; } - } diff --git a/library/Icinga/Protocol/Statusdat/View/MonitoringObjectList.php b/library/Icinga/Protocol/Statusdat/View/MonitoringObjectList.php index 7ddf86fe2..441ae61aa 100755 --- a/library/Icinga/Protocol/Statusdat/View/MonitoringObjectList.php +++ b/library/Icinga/Protocol/Statusdat/View/MonitoringObjectList.php @@ -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 } - } diff --git a/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php b/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php index 44e6f81c6..1a216fad6 100755 --- a/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php +++ b/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php @@ -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); diff --git a/library/Icinga/Util/Format.php b/library/Icinga/Util/Format.php index f7986d5c3..ef0f43d86 100644 --- a/library/Icinga/Util/Format.php +++ b/library/Icinga/Util/Format.php @@ -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) { From 74b9731df5f27a9d0afd1bdce07e0ea1e061bb1d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Sep 2013 11:17:28 +0200 Subject: [PATCH 05/10] Remove auto class requirement from BaseTestCase::createForm() The tests for the respective forms must require the form class. refs #4586 --- library/Icinga/Test/BaseTestCase.php | 45 +++++-------------- .../php/testlib/MonitoringControllerTest.php | 2 +- .../forms/Config/AuthenticationFormTest.php | 1 + .../forms/Config/GeneralFormTest.php | 12 ++--- .../forms/Config/LoggingFormTest.php | 1 + .../Icinga/Test/BaseTestCaseFormTest.php | 5 ++- 6 files changed, 25 insertions(+), 41 deletions(-) diff --git a/library/Icinga/Test/BaseTestCase.php b/library/Icinga/Test/BaseTestCase.php index 324819031..3ec7ccde5 100644 --- a/library/Icinga/Test/BaseTestCase.php +++ b/library/Icinga/Test/BaseTestCase.php @@ -293,43 +293,24 @@ class BaseTestCase extends Zend_Test_PHPUnit_ControllerTestCase implements DbTes } /** - * Instantiate a new form object + * Instantiate a form * - * @param string $formClass Form class to instantiate - * @param array $requestData Request data for the 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 + * @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; - } - - $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 = 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; @@ -338,14 +319,12 @@ class BaseTestCase extends Zend_Test_PHPUnit_ControllerTestCase implements DbTes $request = $this->getRequest(); $request->setMethod('POST'); $request->setPost($requestData); - $form->setRequest($request); $form->setUserPreferences( new Preferences( array() ) ); - return $form; } @@ -404,4 +383,4 @@ class BaseTestCase extends Zend_Test_PHPUnit_ControllerTestCase implements DbTes // @codingStandardsIgnoreStart BaseTestCase::setupDirectories(); -// @codingStandardsIgnoreEnd \ No newline at end of file +// @codingStandardsIgnoreEnd diff --git a/modules/monitoring/test/php/testlib/MonitoringControllerTest.php b/modules/monitoring/test/php/testlib/MonitoringControllerTest.php index 7cb226aff..cf10dca30 100644 --- a/modules/monitoring/test/php/testlib/MonitoringControllerTest.php +++ b/modules/monitoring/test/php/testlib/MonitoringControllerTest.php @@ -41,7 +41,7 @@ use \Icinga\Protocol\Statusdat\Reader; use \Icinga\Web\Controller\ActionController; use \Icinga\Application\DbAdapterFactory; use \Icinga\Module\Monitoring\Backend\Ido; -use \Icinga\Moudle\Monitoring\Backend\Statusdat; +use \Icinga\Module\Monitoring\Backend\Statusdat; use \Test\Monitoring\Testlib\DataSource\TestFixture; use \Test\Monitoring\Testlib\DataSource\DataSourceTestSetup; diff --git a/test/php/application/forms/Config/AuthenticationFormTest.php b/test/php/application/forms/Config/AuthenticationFormTest.php index e0d44ef50..212b9723e 100644 --- a/test/php/application/forms/Config/AuthenticationFormTest.php +++ b/test/php/application/forms/Config/AuthenticationFormTest.php @@ -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; diff --git a/test/php/application/forms/Config/GeneralFormTest.php b/test/php/application/forms/Config/GeneralFormTest.php index 4251bd214..3a375a081 100644 --- a/test/php/application/forms/Config/GeneralFormTest.php +++ b/test/php/application/forms/Config/GeneralFormTest.php @@ -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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -227,4 +227,4 @@ class GeneralFormTest extends BaseTestCase "Asserting the db resource to be displayed when db preference is set" ); } -} \ No newline at end of file +} diff --git a/test/php/application/forms/Config/LoggingFormTest.php b/test/php/application/forms/Config/LoggingFormTest.php index 575a3a168..0187df174 100644 --- a/test/php/application/forms/Config/LoggingFormTest.php +++ b/test/php/application/forms/Config/LoggingFormTest.php @@ -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; diff --git a/test/php/library/Icinga/Test/BaseTestCaseFormTest.php b/test/php/library/Icinga/Test/BaseTestCaseFormTest.php index fe6768902..8210cff10 100644 --- a/test/php/library/Icinga/Test/BaseTestCaseFormTest.php +++ b/test/php/library/Icinga/Test/BaseTestCaseFormTest.php @@ -30,7 +30,10 @@ namespace Tests\Icinga\Test; require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -use Icinga\Test\BaseTestCase; +use \Icinga\Test\BaseTestCase; + +require_once BaseTestCase::$appDir . '/forms/Authentication/LoginForm.php'; +require_once BaseTestCase::$moduleDir . '/monitoring/application/forms/Config/ConfirmRemovalForm.php'; class BaseTestCaseFormTest extends BaseTestCase { From a89631fd92e868ca25aaf753f78d73be76c5dda9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Sep 2013 13:28:53 +0200 Subject: [PATCH 06/10] Tests/Monitoring: Remove useless test ConfirmationFormTest refs #4586 --- .../forms/Command/ConfirmationFormTest.php | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php diff --git a/modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php b/modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php deleted file mode 100644 index 5a515308d..000000000 --- a/modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php +++ /dev/null @@ -1,33 +0,0 @@ -setRequest($this->getRequest()); - - $form->addNote('444 NOTE 1'); - $form->addNote('555 NOTE 2'); - $form->buildForm(); - $content = $form->render($view); - - $this->assertContains('
', $content); - $this->assertContains('
', $content); - $this->assertContains('444 NOTE 1
', $content); - $this->assertContains('555 NOTE 2', $content); - } -} From e3044b8b62f5622a04697f6d4bc0f885cf20573e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Sep 2013 14:00:33 +0200 Subject: [PATCH 07/10] Tests/Monitoring: Remove ScheduleDowntimeFormTest since it's being refactored in another branch refs #4586 --- .../Command/ScheduleDowntimeFormTest.php | 334 ------------------ 1 file changed, 334 deletions(-) delete mode 100644 modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php diff --git a/modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php b/modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php deleted file mode 100644 index b17f05a30..000000000 --- a/modules/monitoring/test/php/application/forms/Command/ScheduleDowntimeFormTest.php +++ /dev/null @@ -1,334 +0,0 @@ - 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 From 6f383abdd1e1df78859a0f68807438d3342bcf11 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Sep 2013 14:01:31 +0200 Subject: [PATCH 08/10] Tests: Let the BaseTestCase require db and form libraries once it's being required Further add function t() and mt() to the global namespace when requiring BaseTestCase refs #4586 --- library/Icinga/Test/BaseTestCase.php | 710 ++++++++++++++------------- library/Icinga/Test/FormTest.php | 5 - 2 files changed, 360 insertions(+), 355 deletions(-) diff --git a/library/Icinga/Test/BaseTestCase.php b/library/Icinga/Test/BaseTestCase.php index 3ec7ccde5..7aefa983a 100644 --- a/library/Icinga/Test/BaseTestCase.php +++ b/library/Icinga/Test/BaseTestCase.php @@ -26,361 +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 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; + if (!function_exists('mt')) { + function mt() + { + return func_get_arg(0); } - - $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(); +} diff --git a/library/Icinga/Test/FormTest.php b/library/Icinga/Test/FormTest.php index 9231e42e9..aacf1b277 100644 --- a/library/Icinga/Test/FormTest.php +++ b/library/Icinga/Test/FormTest.php @@ -44,9 +44,4 @@ interface FormTest * @return Form */ public function createForm($formClass, array $requestData = array()); - - /** - * Require all libraries to instantiate forms - */ - public function requireFormLibraries(); } From 3e4d1aa2fb9305ab78557aa738888ebbd9d181eb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Sep 2013 14:23:01 +0200 Subject: [PATCH 09/10] Monitoring/Tests: Replace BaseFormTest with BaseTestCase refs #4586 --- .../forms/Command/AcknowledgeFormTest.php | 140 +++++++++--------- .../forms/Command/CommentFormTest.php | 63 ++++---- .../ConfirmationWithIdentifierFormTest.php | 98 +++++------- .../Command/CustomNotificationFormTest.php | 29 ++-- .../Command/DelayNotificationFormTest.php | 53 ++++--- .../Command/RescheduleNextCheckFormTest.php | 68 +++++---- .../Command/SubmitPassiveCheckResultTest.php | 97 +++++++----- .../library/Icinga/Web/Form/BaseFormTest.php | 49 ------ 8 files changed, 290 insertions(+), 307 deletions(-) delete mode 100644 test/php/library/Icinga/Web/Form/BaseFormTest.php diff --git a/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php b/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php index f89ce5169..7e9e992ac 100644 --- a/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/AcknowledgeFormTest.php @@ -1,27 +1,27 @@ 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 diff --git a/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php b/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php index 2485b7c59..9a6ae4942 100644 --- a/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/CommentFormTest.php @@ -1,29 +1,31 @@ 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 diff --git a/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php b/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php index 7c3436395..51ed37b3e 100644 --- a/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php @@ -1,81 +1,63 @@ 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' + ); } } diff --git a/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php b/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php index 39a3e72d6..2d5858866 100644 --- a/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php @@ -1,32 +1,33 @@ 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 diff --git a/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php b/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php index 25e8a757d..3d28de233 100644 --- a/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php @@ -1,27 +1,31 @@ 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 diff --git a/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php b/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php index 5d90c6eda..4fc604a24 100644 --- a/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/RescheduleNextCheckFormTest.php @@ -1,26 +1,28 @@ 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 diff --git a/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php b/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php index 085d8120b..5ee877242 100644 --- a/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php +++ b/modules/monitoring/test/php/application/forms/Command/SubmitPassiveCheckResultTest.php @@ -1,68 +1,87 @@ 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' diff --git a/test/php/library/Icinga/Web/Form/BaseFormTest.php b/test/php/library/Icinga/Web/Form/BaseFormTest.php deleted file mode 100644 index d49e9012b..000000000 --- a/test/php/library/Icinga/Web/Form/BaseFormTest.php +++ /dev/null @@ -1,49 +0,0 @@ -createForm($formClass, $data); - } - - /** - * This is just a test to avoid warnings being submitted from the testrunner - * - */ - public function testForRemovingWarnings() - { - $this->assertTrue(true); - } - } -} From 1b858cbdb4eef422199a6b8f0ee009cb066f44bd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Sep 2013 14:35:43 +0200 Subject: [PATCH 10/10] Monitoring: Fix remaining usages of namespace Monitoring without Icinga\Module prefix refs #4586 --- .../Statusdat/View/ObjectRemappingView.php | 2 +- .../controllers/ConfigController.php | 10 ++-- .../Config/Backend/CreateBackendForm.php | 2 +- .../forms/Config/Backend/EditBackendForm.php | 2 +- .../forms/Config/ConfirmRemovalForm.php | 2 +- .../Config/Instance/CreateInstanceForm.php | 2 +- .../Config/Instance/EditInstanceForm.php | 2 +- .../views/scripts/show/history.phtml | 2 +- .../library/Monitoring/Backend/Ido.php | 2 +- .../Monitoring/View/MonitoringView.php | 2 +- .../Icinga/Test/BaseTestCaseFormTest.php | 47 ------------------- 11 files changed, 14 insertions(+), 61 deletions(-) delete mode 100644 test/php/library/Icinga/Test/BaseTestCaseFormTest.php diff --git a/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php b/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php index 1a216fad6..5c2f218c7 100755 --- a/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php +++ b/library/Icinga/Protocol/Statusdat/View/ObjectRemappingView.php @@ -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 */ diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index 76b12df08..cc5f18b4a 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -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 diff --git a/modules/monitoring/application/forms/Config/Backend/CreateBackendForm.php b/modules/monitoring/application/forms/Config/Backend/CreateBackendForm.php index 3f0055451..1e51d7107 100644 --- a/modules/monitoring/application/forms/Config/Backend/CreateBackendForm.php +++ b/modules/monitoring/application/forms/Config/Backend/CreateBackendForm.php @@ -27,7 +27,7 @@ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Config\Backend; +namespace Icinga\Module\Monitoring\Form\Config\Backend; use \Zend_Config; diff --git a/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php b/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php index 8694c493e..58501df97 100644 --- a/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php +++ b/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php @@ -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; diff --git a/modules/monitoring/application/forms/Config/ConfirmRemovalForm.php b/modules/monitoring/application/forms/Config/ConfirmRemovalForm.php index d8008addd..64d914d73 100644 --- a/modules/monitoring/application/forms/Config/ConfirmRemovalForm.php +++ b/modules/monitoring/application/forms/Config/ConfirmRemovalForm.php @@ -27,7 +27,7 @@ // {{{ICINGA_LICENSE_HEADER}}} -namespace Monitoring\Form\Config; +namespace Icinga\Module\Monitoring\Form\Config; use Icinga\Web\Form; diff --git a/modules/monitoring/application/forms/Config/Instance/CreateInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/CreateInstanceForm.php index b46021eed..9a6a4d5f9 100644 --- a/modules/monitoring/application/forms/Config/Instance/CreateInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/CreateInstanceForm.php @@ -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; diff --git a/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php index f04084941..cd7082a81 100644 --- a/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php @@ -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; diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index dc89aea56..b58838045 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -27,7 +27,7 @@ There are no matching history entries right now escape($event->host_name) ?> - +