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();
|
||||
$this->assertValidCsrfToken($checkData);
|
||||
|
||||
$submitted = isset($checkData['btn_submit']);
|
||||
$submitted = true;
|
||||
if ($this->getSubmitLabel()) {
|
||||
$submitted = isset($checkData['btn_submit']);
|
||||
}
|
||||
|
||||
if ($submitted) {
|
||||
$this->preValidation($checkData);
|
||||
}
|
||||
|
|
|
@ -17,16 +17,20 @@ use \Zend_Test_PHPUnit_ControllerTestCase;
|
|||
class AcknowledgeFormTest extends BaseFormTest
|
||||
{
|
||||
const FORMCLASS = "Monitoring\Form\Command\AcknowledgeForm";
|
||||
|
||||
public function testForm()
|
||||
{
|
||||
$form = $this->getRequestForm(array(), self::FORMCLASS);
|
||||
$form->buildForm();
|
||||
$formWithoutExpiration = $this->getRequestForm(array(), self::FORMCLASS);
|
||||
$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()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
|
@ -34,9 +38,9 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'comment' => 'test comment',
|
||||
'persistent' => '0',
|
||||
'expire' => '0',
|
||||
'expiretime' => '',
|
||||
'sticky' => '0',
|
||||
'notify' => '0'
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$this->assertTrue(
|
||||
|
@ -52,9 +56,9 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'comment' => '',
|
||||
'persistent' => '0',
|
||||
'expire' => '0',
|
||||
'expiretime' => '',
|
||||
'sticky' => '0',
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
|
@ -71,7 +75,8 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'expire' => '1',
|
||||
'expiretime' => '',
|
||||
'sticky' => '0',
|
||||
'notify' => '0'
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
|
@ -88,7 +93,8 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'expire' => '1',
|
||||
'expiretime' => 'NOT A DATE',
|
||||
'sticky' => '0',
|
||||
'notify' => '0'
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
$this->assertFalse(
|
||||
$form->isSubmittedAndValid(),
|
||||
|
@ -105,7 +111,8 @@ class AcknowledgeFormTest extends BaseFormTest
|
|||
'expire' => '1',
|
||||
'expiretime' => '2013-07-10 17:32:16',
|
||||
'sticky' => '0',
|
||||
'notify' => '0'
|
||||
'notify' => '0',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
$this->assertTrue(
|
||||
$form->isSubmittedAndValid(),
|
||||
|
|
|
@ -28,9 +28,10 @@ class CommentFormTest extends BaseFormTest
|
|||
public function testCorrectCommentValidation()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'test1',
|
||||
'comment' => 'test2',
|
||||
'sticky' => '0'
|
||||
'author' => 'test1',
|
||||
'comment' => 'test2',
|
||||
'sticky' => '0',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$this->assertTrue(
|
||||
|
|
|
@ -28,7 +28,8 @@ class ConfirmationWithIdentifierFormTest extends BaseFormTest
|
|||
{
|
||||
|
||||
$form = $this->getRequestForm(array(
|
||||
'testval' => 123
|
||||
'testval' => 123,
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form->setFieldLabel('Test1');
|
||||
|
|
|
@ -16,8 +16,9 @@ class CustomNotificationFormTest extends BaseFormTest
|
|||
public function testForm1()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'comment' => 'TEST COMMENT',
|
||||
'author' => 'LAOLA'
|
||||
'comment' => 'TEST COMMENT',
|
||||
'author' => 'LAOLA',
|
||||
'btn_submit' => 'foo'
|
||||
), "Monitoring\Form\Command\CustomNotificationForm");
|
||||
$form->buildForm();
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ class DelayNotificationFormFormTest extends BaseFormTest
|
|||
public function testValidForm()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'minutes' => 12
|
||||
'minutes' => 12,
|
||||
'btn_submit' => 'foo'
|
||||
), 'Monitoring\Form\Command\DelayNotificationForm');
|
||||
|
||||
$form->buildForm();
|
||||
|
|
|
@ -25,7 +25,8 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
|||
|
||||
$form = $this->getRequestForm(array(
|
||||
'checktime' => '2013-10-19 17:30:00',
|
||||
'forcecheck' => 1
|
||||
'forcecheck' => 1,
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
$form->buildForm();
|
||||
|
||||
|
@ -37,7 +38,8 @@ class RescheduleNextCheckFormTest extends BaseFormTest
|
|||
);
|
||||
$form = $this->getRequestForm(array(
|
||||
'checktime' => '2013-10-19 17:30:00',
|
||||
'forcecheck' => 0
|
||||
'forcecheck' => 0,
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$this->assertTrue(
|
||||
|
|
|
@ -16,10 +16,15 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
const FORMCLASS = 'Monitoring\Form\Command\ScheduleDowntimeForm';
|
||||
public function testCorrectFormElementCreation()
|
||||
{
|
||||
$form = $this->getRequestForm(array(), self::FORMCLASS);
|
||||
$form->buildForm();
|
||||
$formFixed = $this->getRequestForm(array(), self::FORMCLASS);
|
||||
$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->setWithChildren(true);
|
||||
|
@ -32,14 +37,15 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
public function testCorrectValidationWithChildrend()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '2013-07-17 10:30:00',
|
||||
'endtime' => '2013-07-17 10:30:00',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '2013-07-17 10:30:00',
|
||||
'endtime' => '2013-07-17 10:30:00',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'btn_submit' => 'foo',
|
||||
// 'childobjects' => '',
|
||||
), self::FORMCLASS);
|
||||
|
||||
|
@ -51,14 +57,15 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
'Asserting a correct fixed downtime form to be considered valid'
|
||||
);
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '2013-07-17 10:30:00',
|
||||
'endtime' => '2013-07-17 10:30:00',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
||||
'hours' => '10',
|
||||
'minutes' => '10',
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '2013-07-17 10:30:00',
|
||||
'endtime' => '2013-07-17 10:30:00',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
|
||||
'hours' => '10',
|
||||
'minutes' => '10',
|
||||
'btn_submit' => 'foo'
|
||||
// 'childobjects' => '',
|
||||
), self::FORMCLASS);
|
||||
$form->setWithChildren(true);
|
||||
|
@ -247,14 +254,15 @@ class ScheduleDowntimeFormTest extends BaseFormTest
|
|||
public function testCorrectScheduleDowntimeWithoutChildrenForm()
|
||||
{
|
||||
$form = $this->getRequestForm(array(
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '2013-07-17 10:30:00',
|
||||
'endtime' => '2013-07-17 10:30:00',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'author' => 'TEST_AUTHOR',
|
||||
'comment' => 'DING DING',
|
||||
'triggered' => '4',
|
||||
'starttime' => '2013-07-17 10:30:00',
|
||||
'endtime' => '2013-07-17 10:30:00',
|
||||
'type' => ScheduleDowntimeForm::TYPE_FIXED,
|
||||
'hours' => '',
|
||||
'minutes' => '',
|
||||
'btn_submit' => 'foo',
|
||||
'childobjects' => '0',
|
||||
), self::FORMCLASS);
|
||||
$form->setWithChildren(false);
|
||||
|
|
|
@ -59,7 +59,8 @@ class SubmitPassiveCheckResultFormTest extends BaseFormTest
|
|||
$form = $this->getRequestForm(array(
|
||||
'pluginstate' => 0,
|
||||
'checkoutput' => 'DING',
|
||||
'performancedata' => ''
|
||||
'performancedata' => '',
|
||||
'btn_submit' => 'foo'
|
||||
), self::FORMCLASS);
|
||||
|
||||
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
|
||||
|
|
Loading…
Reference in New Issue