Implement dynamic form elements
Rename "isPostAndValid" to "isSubmittedAndValid" and refactor it. Add possibility for specific form elements to auto-submit their form. refs #4439
This commit is contained in:
parent
cc77a55435
commit
98e7ab02db
|
@ -69,8 +69,7 @@ class AuthenticationController extends ActionController
|
|||
$this->redirectNow('index?_render=body');
|
||||
}
|
||||
|
||||
if ($this->view->form->isPostAndValid()) {
|
||||
|
||||
if ($this->view->form->isSubmittedAndValid()) {
|
||||
$credentials->setUsername($this->view->form->getValue('username'));
|
||||
$credentials->setPassword($this->view->form->getValue('password'));
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ In here you can add elements to your form, add validations and filters of your
|
|||
choice. The creation method is invoked lazy just before a form is rendered or
|
||||
*isValid()* is called.
|
||||
|
||||
#### Calling is *IsPostAndValid()*
|
||||
#### Calling is *isSubmittedAndValid()*
|
||||
|
||||
*IsPostAndValid()* is used to test of all needed parameters there. It combines
|
||||
testing for post request and pulls out the data from request object to handle
|
||||
over an array for Zend native method *isValid()*
|
||||
*isSubmittedAndValid()* is used to check whether the form is ready to be processed or not.
|
||||
It ensures that the current request method is POST, that the form was manually submitted
|
||||
and that the data provided in the request is valid and gets repopulated in case its invalid.
|
||||
|
||||
#### Pre validation
|
||||
|
||||
|
|
|
@ -171,23 +171,58 @@ abstract class Form extends \Zend_Form
|
|||
}
|
||||
|
||||
/**
|
||||
* Test if data from array or request is valid
|
||||
* Enable automatic submission
|
||||
*
|
||||
* Enables automatic submission of this form once the user edits specific elements.
|
||||
*
|
||||
* @param array $trigger_elements The element names which should auto-submit the form
|
||||
* @throws ProgrammingError When the form has no name or an element is found
|
||||
* which does not yet exist
|
||||
*/
|
||||
final public function enableAutoSubmit($trigger_elements)
|
||||
{
|
||||
$form_name = $this->getName();
|
||||
if ($form_name === null) {
|
||||
throw new ProgrammingError('You need to set a name for this form.');
|
||||
}
|
||||
|
||||
foreach ($trigger_elements as $element_name) {
|
||||
$element = $this->getElement($element_name);
|
||||
if ($element !== null) {
|
||||
$element->setAttrib('onchange', '$("#' . $form_name . '").submit();');
|
||||
} else {
|
||||
throw new ProgrammingError(
|
||||
'You need to add the element "' . $element_name . '" to' .
|
||||
' the form before automatic submission can be enabled!'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the form was submitted with a valid request
|
||||
*
|
||||
* Ensures that the current request method is POST, that the
|
||||
* form was manually submitted and that the data provided in
|
||||
* the request is valid and gets repopulated in case its invalid.
|
||||
*
|
||||
* If $data is null, internal request is selected to test validity
|
||||
* @return bool
|
||||
*/
|
||||
public function isPostAndValid()
|
||||
public function isSubmittedAndValid()
|
||||
{
|
||||
if ($this->getRequest()->isPost() === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$checkData = $this->getRequest()->getParams();
|
||||
|
||||
$this->buildForm();
|
||||
$checkData = $this->getRequest()->getParams();
|
||||
$this->assertValidCsrfToken($checkData);
|
||||
$this->preValidation($checkData);
|
||||
return parent::isValid($checkData);
|
||||
|
||||
$submitted = isset($checkData['btn_submit']);
|
||||
if ($submitted) {
|
||||
$this->preValidation($checkData);
|
||||
}
|
||||
return parent::isValid($checkData) && $submitted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -97,8 +97,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
public function postDispatch()
|
||||
{
|
||||
if ($this->issetForm()) {
|
||||
if ($this->form->isPostAndValid()) {
|
||||
|
||||
if ($this->form->isSubmittedAndValid()) {
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
$this->_helper->layout()->disableLayout();
|
||||
}
|
||||
|
@ -254,7 +253,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Disable active checks for this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->disableActiveChecks($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +271,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Enable active checks for this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->enableActiveChecks($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +288,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->scheduleCheck($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -309,7 +308,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->submitCheckResult($this->view->objects, $form->getState(), $form->getOutput(), $form->getPerformancedata());
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +326,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Stop obsessing over this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->stopObsessing($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +344,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Start obsessing over this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->startObsessing($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +362,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Passive checks for this object will be omitted.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->disablePassiveChecks($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +380,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Passive checks for this object will be accepted.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->enableActiveChecks($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +398,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Notifications for this object will be disabled.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->disableNotifications($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -416,7 +415,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Notifications for this object will be enabled.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->enableNotifications($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +431,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->setRequest($this->getRequest());
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$author = $this->getRequest()->getUser()->getUsername();
|
||||
$this->target->sendCustomNotification(
|
||||
$this->view->objects,
|
||||
|
@ -454,7 +453,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->setWithChildren(false);
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->scheduleDowntime($this->view->objects, $form->getDowntime());
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +471,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->setWithChildren(true);
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->scheduleDowntime($this->view->objects, $form->getDowntime());
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +489,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Remove downtime(s) from this host and its services.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->removeDowntime($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +507,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Notifications for this host and its services will be disabled.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->disableNotifications($this->view->objects);
|
||||
$this->target->disableNotificationsForServices($this->view->objects);
|
||||
}
|
||||
|
@ -527,7 +526,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Notifications for this host and its services will be enabled.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->enableNotifications($this->view->objects);
|
||||
$this->target->enableNotificationsForServices($this->view->objects);
|
||||
}
|
||||
|
@ -547,7 +546,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
if ($form->isForced()) {
|
||||
$this->target->scheduleForcedCheck($this->view->objects, time());
|
||||
$this->target->scheduleForcedCheck($this->view->objects, time(), true);
|
||||
|
@ -571,7 +570,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Disable active checks for this host and its services.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->disableActiveChecks($this->view->objects);
|
||||
$this->target->disableActiveChecksWithChildren($this->view->objects);
|
||||
}
|
||||
|
@ -590,7 +589,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Enable active checks for this host and its services.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->enableActiveChecks($this->view->objects);
|
||||
$this->target->enableActiveChecksWithChildren($this->view->objects);
|
||||
}
|
||||
|
@ -609,7 +608,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Disable event handler for this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->disableEventHandler($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -627,7 +626,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Enable event handler for this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->enableEventHandler($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -645,7 +644,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Disable flapping detection for this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->disableFlappingDetection($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -663,7 +662,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Enable flapping detection for this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->enableFlappingDetection($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -680,7 +679,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->addComment($this->view->objects, $form->getComment());
|
||||
}
|
||||
}
|
||||
|
@ -698,7 +697,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Reset modified attributes to its default.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->resetAttributes($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -715,7 +714,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->acknowledge($this->view->objects, $form->getAcknowledgement());
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +732,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
$form->addNote(t('Remove problem acknowledgement for this object.'));
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->removeAcknowledge($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
@ -750,7 +749,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->delayNotification($this->view->objects, $form->getDelayTime());
|
||||
}
|
||||
}
|
||||
|
@ -772,7 +771,7 @@ class Monitoring_CommandController extends ModuleActionController
|
|||
|
||||
$this->setForm($form);
|
||||
|
||||
if ($form->isPostAndValid() === true) {
|
||||
if ($form->IsSubmittedAndValid() === true) {
|
||||
$this->target->removeDowntime($this->view->objects);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ class ConfirmationForm extends Form
|
|||
if ($this->getCancelLabel()) {
|
||||
$cancelLabel = new \Zend_Form_Element_Reset(
|
||||
array(
|
||||
'name' => 'reset',
|
||||
'name' => 'btn_reset',
|
||||
'label' => $this->getCancelLabel(),
|
||||
'class' => 'btn pull-right'
|
||||
)
|
||||
|
@ -187,7 +187,7 @@ class ConfirmationForm extends Form
|
|||
if ($this->getSubmitLabel()) {
|
||||
$submitButton = new \Zend_Form_Element_Submit(
|
||||
array(
|
||||
'name' => 'submit',
|
||||
'name' => 'btn_submit',
|
||||
'label' => $this->getSubmitLabel(),
|
||||
'class' => 'btn btn-primary pull-right'
|
||||
)
|
||||
|
|
|
@ -40,7 +40,7 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
), self::FORMCLASS);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting a correct form to be validated correctly"
|
||||
);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'notify' => '0',
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting a missing comment text to cause validation errors"
|
||||
);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'notify' => '0'
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting a missing expire time to cause validation errors when expire is 1"
|
||||
);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'notify' => '0'
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert incorrect dates to be recognized when validating expiretime"
|
||||
);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'notify' => '0'
|
||||
), self::FORMCLASS);
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert that correct expire time acknowledgement is considered valid"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class CommentFormTest extends BaseFormTest
|
|||
), self::FORMCLASS);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting correct comment form to be considered valid"
|
||||
);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class CommentFormTest extends BaseFormTest
|
|||
'sticky' => '0'
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting missing comment text in comment form to cause validation errors"
|
||||
);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class CommentFormTest extends BaseFormTest
|
|||
'sticky' => '0'
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting missing comment author to cause validation errors"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class ConfirmationWithIdentifierFormTest extends BaseFormTest
|
|||
$form->setSubmitLabel('DING DING');
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting correct confirmation with id to be valid"
|
||||
);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class ConfirmationWithIdentifierFormTest extends BaseFormTest
|
|||
), self::FORMCLASS);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting an invalid (empty) value to cause validation errors"
|
||||
);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class ConfirmationWithIdentifierFormTest extends BaseFormTest
|
|||
), self::FORMCLASS);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting an non numeric value to cause validation errors"
|
||||
);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class ConfirmationWithIdentifierFormTest extends BaseFormTest
|
|||
), self::FORMCLASS);
|
||||
$form->buildForm();
|
||||
|
||||
$this->assertTrue($form->isPostAndValid());
|
||||
$this->assertTrue($form->isSubmittedAndValid());
|
||||
|
||||
$this->assertEquals('123123666', $form->getElement('objectid')->getValue());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class CustomNotificationFormTest extends BaseFormTest
|
|||
$form->buildForm();
|
||||
|
||||
$this->assertCount(7, $form->getElements());
|
||||
$this->assertTrue($form->isPostAndValid());
|
||||
$this->assertTrue($form->isSubmittedAndValid());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class DelayNotificationFormFormTest extends BaseFormTest
|
|||
$this->assertTrue($element->isRequired(), "Assert minutes to be declared as required");
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert a correct DelayNotificationForm to be considered valid"
|
||||
);
|
||||
|
||||
|
@ -44,7 +44,7 @@ class DelayNotificationFormFormTest extends BaseFormTest
|
|||
$form->buildForm();
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Asserting invalid minutes (NaN) to cause validation errors"
|
||||
);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
|||
$this->assertCount(6, $form->getElements());
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting a reschedule form with correct time and forececheck=1 to be valid'
|
||||
);
|
||||
$form = $this->getRequestForm(array(
|
||||
|
@ -41,7 +41,7 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
|||
), self::FORMCLASS);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting a reschedule form with correct time and forecheck=0 to be valid'
|
||||
);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
|||
), self::FORMCLASS);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting an logically invalid checktime to be considered as invalid reschedule data'
|
||||
);
|
||||
|
||||
|
@ -65,7 +65,7 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
|||
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting an invalid non-numeric checktime to be considered as invalid reschedule data'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting a correct fixed downtime form to be considered valid'
|
||||
);
|
||||
$form = $this->getRequestForm(array(
|
||||
|
@ -64,7 +64,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Asserting a correct flexible downtime form to be considered valid'
|
||||
);
|
||||
|
||||
|
@ -86,7 +86,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert missing hours and minutes in downtime form to cause failing validation'
|
||||
);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert missing author to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert missing comment to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert invalid trigger field to cause validation to fail'
|
||||
);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert incorrect start time to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert invalid endtime to cause validation errors in fixed downtime'
|
||||
);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert negative hours to cause validation errors in flexible downtime'
|
||||
);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(true);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
'Assert non numeric valud to cause validation errors in flexible downtime '
|
||||
);
|
||||
|
||||
|
@ -261,7 +261,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert a correct schedule downtime without children form to be considered valid"
|
||||
);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(false);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert and incorrect (non-numeric) childobjects value to cause validation errors"
|
||||
);
|
||||
|
||||
|
@ -299,7 +299,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
$form->setWithChildren(false);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert and incorrect (numeric) childobjects value to cause validation errors"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
|||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
|
||||
$this->assertTrue(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert a correct passive service check form to pass form validation"
|
||||
);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
|||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert empty checkoutput to cause validation errors in passive service check "
|
||||
);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
|||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
|
||||
$this->assertFalse(
|
||||
$form->isPostAndValid(),
|
||||
$form->isSubmittedAndValid(),
|
||||
"Assert invalid (non-numeric) state to cause validation errors in passive service check"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Tests\Icinga\Regression
|
|||
$form = new LoginForm();
|
||||
$form->setRequest($request);
|
||||
$form->buildForm();
|
||||
$this->assertTrue($form->isPostAndValid());
|
||||
$this->assertTrue($form->isSubmittedAndValid());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue