Update command form tests
Update command form tests so that they reflect the new dynamic functionality and the correct purpose of "isSubmittedAndValid". refs #4439
This commit is contained in:
parent
8efbe6f613
commit
f26af0eb12
|
@ -309,7 +309,11 @@ abstract class Form extends \Zend_Form
|
||||||
$checkData = $this->getRequest()->getParams();
|
$checkData = $this->getRequest()->getParams();
|
||||||
$this->assertValidCsrfToken($checkData);
|
$this->assertValidCsrfToken($checkData);
|
||||||
|
|
||||||
|
$submitted = true;
|
||||||
|
if ($this->getSubmitLabel()) {
|
||||||
$submitted = isset($checkData['btn_submit']);
|
$submitted = isset($checkData['btn_submit']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($submitted) {
|
if ($submitted) {
|
||||||
$this->preValidation($checkData);
|
$this->preValidation($checkData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,20 @@ use \Zend_Test_PHPUnit_ControllerTestCase;
|
||||||
class AcknowledgeFormTest extends BaseFormTest
|
class AcknowledgeFormTest extends BaseFormTest
|
||||||
{
|
{
|
||||||
const FORMCLASS = "Monitoring\Form\Command\AcknowledgeForm";
|
const FORMCLASS = "Monitoring\Form\Command\AcknowledgeForm";
|
||||||
|
|
||||||
public function testForm()
|
public function testForm()
|
||||||
{
|
{
|
||||||
$form = $this->getRequestForm(array(), self::FORMCLASS);
|
$formWithoutExpiration = $this->getRequestForm(array(), self::FORMCLASS);
|
||||||
$form->buildForm();
|
$formWithoutExpiration->buildForm();
|
||||||
|
$formWithExpiration = $this->getRequestForm(array(
|
||||||
|
'expire' => '1'
|
||||||
|
), self::FORMCLASS);
|
||||||
|
$formWithExpiration->buildForm();
|
||||||
|
|
||||||
$this->assertCount(11, $form->getElements());
|
$this->assertCount(10, $formWithoutExpiration->getElements());
|
||||||
|
$this->assertCount(11, $formWithExpiration->getElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function testValidateCorrectForm()
|
public function testValidateCorrectForm()
|
||||||
{
|
{
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
|
@ -34,9 +38,9 @@ class AcknowledgeFormTest extends BaseFormTest
|
||||||
'comment' => 'test comment',
|
'comment' => 'test comment',
|
||||||
'persistent' => '0',
|
'persistent' => '0',
|
||||||
'expire' => '0',
|
'expire' => '0',
|
||||||
'expiretime' => '',
|
|
||||||
'sticky' => '0',
|
'sticky' => '0',
|
||||||
'notify' => '0'
|
'notify' => '0',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
|
@ -52,9 +56,9 @@ class AcknowledgeFormTest extends BaseFormTest
|
||||||
'comment' => '',
|
'comment' => '',
|
||||||
'persistent' => '0',
|
'persistent' => '0',
|
||||||
'expire' => '0',
|
'expire' => '0',
|
||||||
'expiretime' => '',
|
|
||||||
'sticky' => '0',
|
'sticky' => '0',
|
||||||
'notify' => '0',
|
'notify' => '0',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$form->isSubmittedAndValid(),
|
$form->isSubmittedAndValid(),
|
||||||
|
@ -71,7 +75,8 @@ class AcknowledgeFormTest extends BaseFormTest
|
||||||
'expire' => '1',
|
'expire' => '1',
|
||||||
'expiretime' => '',
|
'expiretime' => '',
|
||||||
'sticky' => '0',
|
'sticky' => '0',
|
||||||
'notify' => '0'
|
'notify' => '0',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$form->isSubmittedAndValid(),
|
$form->isSubmittedAndValid(),
|
||||||
|
@ -88,7 +93,8 @@ class AcknowledgeFormTest extends BaseFormTest
|
||||||
'expire' => '1',
|
'expire' => '1',
|
||||||
'expiretime' => 'NOT A DATE',
|
'expiretime' => 'NOT A DATE',
|
||||||
'sticky' => '0',
|
'sticky' => '0',
|
||||||
'notify' => '0'
|
'notify' => '0',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$form->isSubmittedAndValid(),
|
$form->isSubmittedAndValid(),
|
||||||
|
@ -105,7 +111,8 @@ class AcknowledgeFormTest extends BaseFormTest
|
||||||
'expire' => '1',
|
'expire' => '1',
|
||||||
'expiretime' => '2013-07-10 17:32:16',
|
'expiretime' => '2013-07-10 17:32:16',
|
||||||
'sticky' => '0',
|
'sticky' => '0',
|
||||||
'notify' => '0'
|
'notify' => '0',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$form->isSubmittedAndValid(),
|
$form->isSubmittedAndValid(),
|
||||||
|
|
|
@ -30,7 +30,8 @@ class CommentFormTest extends BaseFormTest
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
'author' => 'test1',
|
'author' => 'test1',
|
||||||
'comment' => 'test2',
|
'comment' => 'test2',
|
||||||
'sticky' => '0'
|
'sticky' => '0',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
|
|
|
@ -28,7 +28,8 @@ class ConfirmationWithIdentifierFormTest extends BaseFormTest
|
||||||
{
|
{
|
||||||
|
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
'testval' => 123
|
'testval' => 123,
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
|
|
||||||
$form->setFieldLabel('Test1');
|
$form->setFieldLabel('Test1');
|
||||||
|
|
|
@ -17,7 +17,8 @@ class CustomNotificationFormTest extends BaseFormTest
|
||||||
{
|
{
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
'comment' => 'TEST COMMENT',
|
'comment' => 'TEST COMMENT',
|
||||||
'author' => 'LAOLA'
|
'author' => 'LAOLA',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), "Monitoring\Form\Command\CustomNotificationForm");
|
), "Monitoring\Form\Command\CustomNotificationForm");
|
||||||
$form->buildForm();
|
$form->buildForm();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ class DelayNotificationFormFormTest extends BaseFormTest
|
||||||
public function testValidForm()
|
public function testValidForm()
|
||||||
{
|
{
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
'minutes' => 12
|
'minutes' => 12,
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), 'Monitoring\Form\Command\DelayNotificationForm');
|
), 'Monitoring\Form\Command\DelayNotificationForm');
|
||||||
|
|
||||||
$form->buildForm();
|
$form->buildForm();
|
||||||
|
|
|
@ -25,7 +25,8 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
||||||
|
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
'checktime' => '2013-10-19 17:30:00',
|
'checktime' => '2013-10-19 17:30:00',
|
||||||
'forcecheck' => 1
|
'forcecheck' => 1,
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
$form->buildForm();
|
$form->buildForm();
|
||||||
|
|
||||||
|
@ -37,7 +38,8 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
||||||
);
|
);
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
'checktime' => '2013-10-19 17:30:00',
|
'checktime' => '2013-10-19 17:30:00',
|
||||||
'forcecheck' => 0
|
'forcecheck' => 0,
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
|
|
|
@ -16,10 +16,15 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
||||||
const FORMCLASS = 'Monitoring\Form\Command\ScheduleDowntimeForm';
|
const FORMCLASS = 'Monitoring\Form\Command\ScheduleDowntimeForm';
|
||||||
public function testCorrectFormElementCreation()
|
public function testCorrectFormElementCreation()
|
||||||
{
|
{
|
||||||
$form = $this->getRequestForm(array(), self::FORMCLASS);
|
$formFixed = $this->getRequestForm(array(), self::FORMCLASS);
|
||||||
$form->buildForm();
|
$formFixed->buildForm();
|
||||||
|
$formFlexible = $this->getRequestForm(array(
|
||||||
|
'type' => 'flexible'
|
||||||
|
), self::FORMCLASS);
|
||||||
|
$formFlexible->buildForm();
|
||||||
|
|
||||||
$this->assertCount(13, $form->getElements());
|
$this->assertCount(11, $formFixed->getElements());
|
||||||
|
$this->assertCount(13, $formFlexible->getElements());
|
||||||
|
|
||||||
$form = $this->getRequestForm(array(), self::FORMCLASS);
|
$form = $this->getRequestForm(array(), self::FORMCLASS);
|
||||||
$form->setWithChildren(true);
|
$form->setWithChildren(true);
|
||||||
|
@ -40,6 +45,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
||||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||||
'hours' => '',
|
'hours' => '',
|
||||||
'minutes' => '',
|
'minutes' => '',
|
||||||
|
'btn_submit' => 'foo',
|
||||||
// 'childobjects' => '',
|
// 'childobjects' => '',
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
|
|
||||||
|
@ -59,6 +65,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
||||||
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
||||||
'hours' => '10',
|
'hours' => '10',
|
||||||
'minutes' => '10',
|
'minutes' => '10',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
// 'childobjects' => '',
|
// 'childobjects' => '',
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
$form->setWithChildren(true);
|
$form->setWithChildren(true);
|
||||||
|
@ -255,6 +262,7 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
||||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||||
'hours' => '',
|
'hours' => '',
|
||||||
'minutes' => '',
|
'minutes' => '',
|
||||||
|
'btn_submit' => 'foo',
|
||||||
'childobjects' => '0',
|
'childobjects' => '0',
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
$form->setWithChildren(false);
|
$form->setWithChildren(false);
|
||||||
|
|
|
@ -59,7 +59,8 @@ class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
||||||
$form = $this->getRequestForm(array(
|
$form = $this->getRequestForm(array(
|
||||||
'pluginstate' => 0,
|
'pluginstate' => 0,
|
||||||
'checkoutput' => 'DING',
|
'checkoutput' => 'DING',
|
||||||
'performancedata' => ''
|
'performancedata' => '',
|
||||||
|
'btn_submit' => 'foo'
|
||||||
), self::FORMCLASS);
|
), self::FORMCLASS);
|
||||||
|
|
||||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||||
|
|
Loading…
Reference in New Issue