diff --git a/modules/monitoring/application/forms/Command/CommandWithIdentifierForm.php b/modules/monitoring/application/forms/Command/CommandWithIdentifierForm.php deleted file mode 100644 index cfc0bfaff..000000000 --- a/modules/monitoring/application/forms/Command/CommandWithIdentifierForm.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - */ -// {{{ICINGA_LICENSE_HEADER}}} - -namespace Icinga\Module\Monitoring\Form\Command; - -use \Zend_Form_Element_Hidden; - -/** - * Form to handle confirmations with a single value processed - */ -class CommandWithIdentifierForm extends CommandForm -{ - /** - * Identifier for data field - * - * @var string - */ - private $fieldName = 'objectid'; - - /** - * Label for the field - * - * Human readable sting, must be translated before. - * - * @var string - */ - private $fieldLabel; - - /** - * Setter for field label - * - * @param string $fieldLabel - */ - public function setFieldLabel($fieldLabel) - { - $this->fieldLabel = $fieldLabel; - } - - /** - * Getter for field label - * - * @return string - */ - public function getFieldLabel() - { - return $this->fieldLabel; - } - - /** - * Setter for field name - * - * @param string $fieldName - */ - public function setFieldName($fieldName) - { - $this->fieldName = $fieldName; - } - - /** - * Getter for field name - * - * @return string - */ - public function getFieldName() - { - return $this->fieldName; - } - - /** - * Create corresponding field for object configuration - * @return Zend_Form_Element_Hidden - */ - private function createObjectField() - { - $value = $this->getRequest()->getParam($this->getFieldName()); - $fieldLabel = $this->getFieldLabel(); - - $hiddenField = new Zend_Form_Element_Hidden($this->getFieldName()); - $hiddenField->setValue($value); - $hiddenField->setRequired(true); - $hiddenField->addValidator( - 'digits', - true - ); - - $hiddenField->removeDecorator('Label'); - - $hiddenField->addDecorator( - 'Callback', - array( - 'callback' => function () use ($value, $fieldLabel) { - return sprintf( - '%s %s "%s"', - $fieldLabel, - t('is'), - (isset($value)) ? $value : t('unset') - ); - } - ) - ); - - return $hiddenField; - } - - /** - * Interface method to build the form - * @see CommandForm::create - */ - protected function create() - { - $this->addElement($this->createObjectField()); - parent::create(); - } -} diff --git a/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php b/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php deleted file mode 100644 index 51ed37b3e..000000000 --- a/modules/monitoring/test/php/application/forms/Command/ConfirmationWithIdentifierFormTest.php +++ /dev/null @@ -1,63 +0,0 @@ -createForm( - self::FORM_CLASS, - array( - 'object_id' => '', - 'btn_submit' => 'Submit' - ) - ); - $this->assertFalse( - $form->isSubmittedAndValid(), - 'Missing object_id must be considered not valid' - ); - } - - public function testFormInvalidWhenObjectIdNonDigit() - { - $form = $this->createForm( - self::FORM_CLASS, - array( - 'object_id' => 'A Service', - 'btn_submit' => 'Submit' - ) - ); - $this->assertFalse( - $form->isSubmittedAndValid(), - 'Non numeric input must be considered not valid' - ); - } - - public function testFormValidWhenObjectIdIsDigit() - { - $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/testlib/MonitoringControllerTest.php b/modules/monitoring/test/php/testlib/MonitoringControllerTest.php index d281e3ee6..4e2ac46d0 100644 --- a/modules/monitoring/test/php/testlib/MonitoringControllerTest.php +++ b/modules/monitoring/test/php/testlib/MonitoringControllerTest.php @@ -228,7 +228,8 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest */ public function requireController($controller, $backend) { - require_once($this->moduleDir.'/application/controllers/'.$controller.'.php'); + require_once($this->moduleDir . '/library/Monitoring/Controller.php'); + require_once($this->moduleDir . '/application/controllers/'.$controller.'.php'); $controllerName = '\Monitoring_'.ucfirst($controller); $request = $this->getRequest(); if ($backend == 'statusdat') {