Remove command form tests

refs #5525
This commit is contained in:
Johannes Meyer 2014-09-09 09:27:04 +02:00
parent 1137c010a8
commit c8bdb70d06
7 changed files with 0 additions and 788 deletions

View File

@ -1,111 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Module\Monitoring\Application\Forms\Command;
use Icinga\Test\BaseTestCase;
class AcknowledgeFormTest extends BaseTestCase
{
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\AcknowledgeForm';
public function testFormValid()
{
$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->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'
);
}
public function testFormInvalidWhenCommentMissing()
{
$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'
);
}
public function testFormInvalidWhenExpireTimeMissingAndExpireSet()
{
$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'
);
}
public function testFormInvalidWhenExpireTimeIsIncorrectAndExpireSet()
{
$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'
);
}
}

View File

@ -1,64 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Module\Monitoring\Application\Forms\Command;
use Icinga\Test\BaseTestCase;
class CommentFormTest extends BaseTestCase
{
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\CommentForm';
public function testCorrectCommentValidation()
{
$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'
);
}
public function testFormInvalidWhenCommentMissing()
{
$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'
);
}
public function testFormInvalidWhenAuthorMissing()
{
$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'
);
}
}

View File

@ -1,28 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Module\Monitoring\Application\Forms\Command;
use Icinga\Test\BaseTestCase;
class CustomNotificationFormTest extends BaseTestCase
{
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\CustomNotificationForm';
public function testFormInvalidWhenCommentMissing()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'Author',
'comment' => '',
'btn_submit' => 'Submit'
)
);
$this->assertFalse(
$form->isSubmittedAndValid(),
'Missing comment must be considered not valid'
);
}
}

View File

@ -1,58 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Module\Monitoring\Application\Forms\Command;
use Icinga\Test\BaseTestCase;
use Icinga\Module\Monitoring\Form\Command\DelayNotificationForm;
class DelayNotificationFormTest extends BaseTestCase
{
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\DelayNotificationForm';
public function testFormInvalidWhenNotificationDelayMissing()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'minutes' => '',
'btn_submit' => 'Submit'
)
);
$this->assertFalse(
$form->isSubmittedAndValid(),
'Missing notification delay must be considered invalid'
);
}
public function testFormInvalidWhenNotificationDelayNaN()
{
$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'
);
}
public function testFormInvalidWhenNotificationDelayOverflows()
{
$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'
);
}
}

View File

@ -1,54 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Module\Monitoring\Application\Forms\Command;
use Icinga\Test\BaseTestCase;
class RescheduleNextCheckFormTest extends BaseTestCase
{
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\RescheduleNextCheckForm';
public function testFormInvalidWhenChecktimeIsIncorrect()
{
$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->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->createForm(
self::FORM_CLASS,
array(
'checktime' => '',
'forcecheck' => 0,
'btn_submit' => 'Submit'
)
);
$this->assertFalse(
$form3->isSubmittedAndValid(),
'Missing checktime must be considered invalid'
);
}
}

View File

@ -1,356 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Module\Monitoring\Application\Forms\Command;
use Icinga\Test\BaseTestCase;
use Icinga\Module\Monitoring\Form\Command\ScheduleDowntimeForm;
class ScheduleDowntimeFormTest extends BaseTestCase
{
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\ScheduleDowntimeForm';
public function testCorrectFormElementCreation()
{
$formFixed = $this->createForm(self::FORM_CLASS);
$formFixed->setCurrentDowntimes(array('foo'));
$formFixed->buildForm();
$formFlexible = $this->createForm(
self::FORM_CLASS,
array(
'type' => 'flexible'
)
);
$formFlexible->setCurrentDowntimes(array('foo'));
$formFlexible->buildForm();
$form = $this->createForm(self::FORM_CLASS);
$form->setCurrentDowntimes(array('foo'));
$form->setWithChildren(true);
$form->buildForm();
}
public function testCorrectValidationWithChildrend()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'TEST_AUTHOR',
'comment' => 'DING DING',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FIXED,
'hours' => '',
'minutes' => '',
'btn_submit' => 'foo',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertTrue(
$form->isSubmittedAndValid(),
'Asserting a correct fixed downtime form to be considered valid'
);
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'TEST_AUTHOR',
'comment' => 'DING DING',
'triggered' => '0',
'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'
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertTrue(
$form->isSubmittedAndValid(),
'Asserting a correct flexible downtime form to be considered valid'
);
}
public function testMissingFlexibleDurationRecognition()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'TEST_AUTHOR',
'comment' => 'DING DING',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
'hours' => '',
'minutes' => '',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert missing hours and minutes in downtime form to cause failing validation'
);
}
public function testMissingAuthorRecognition()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => '',
'comment' => 'DING DING',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FIXED,
'hours' => '',
'minutes' => '',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert missing author to cause validation errors in fixed downtime'
);
}
public function testMissingCommentRecognition()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'OK',
'comment' => '',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FIXED,
'hours' => '',
'minutes' => '',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert missing comment to cause validation errors in fixed downtime'
);
}
public function testInvalidTriggeredFieldValueRecognition()
{
$form = $this->createForm(
self::FORM_CLASS,
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' => '',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert invalid trigger field to cause validation to fail'
);
}
public function testInvalidStartTimeRecognition()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'OK',
'comment' => 'OK',
'triggered' => '0',
'starttime' => '17/07/2013',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FIXED,
'hours' => '',
'minutes' => '',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert incorrect start time to cause validation errors in fixed downtime'
);
}
public function testInvalidEndTimeRecognition()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'OK',
'comment' => 'OK',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => 'DING',
'type' => ScheduleDowntimeForm::TYPE_FIXED,
'hours' => '',
'minutes' => '',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert invalid endtime to cause validation errors in fixed downtime'
);
}
public function testInvalidHoursValueRecognitionInFlexibleDowntime()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'OK',
'comment' => 'OK',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
'hours' => '-1',
'minutes' => '12',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert negative hours to cause validation errors in flexible downtime'
);
}
public function testInvalidMinutesValueRecognitionInFlexibleDowntime()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'OK',
'comment' => 'OK',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FLEXIBLE,
'hours' => '12',
'minutes' => 'DING',
)
);
$form->setWithChildren(true);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert non numeric valud to cause validation errors in flexible downtime '
);
}
public function testCorrectScheduleDowntimeWithoutChildrenForm()
{
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'TEST_AUTHOR',
'comment' => 'DING DING',
'triggered' => '0',
'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',
)
);
$form->setWithChildren(false);
$form->setCurrentDowntimes(array('foo'));
$this->assertTrue(
$form->isSubmittedAndValid(),
'Assert a correct schedule downtime without children form to be considered valid'
);
}
public function testIncorrectChildObjectsRecognition() {
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'TEST_AUTHOR',
'comment' => 'DING DING',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FIXED,
'hours' => '',
'minutes' => '',
'childobjects' => 'AHA',
)
);
$form->setWithChildren(false);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert and incorrect (non-numeric) childobjects value to cause validation errors'
);
$form = $this->createForm(
self::FORM_CLASS,
array(
'author' => 'TEST_AUTHOR',
'comment' => 'DING DING',
'triggered' => '0',
'starttime' => '17/07/2013 10:30 AM',
'endtime' => '18/07/2013 10:30 AM',
'type' => ScheduleDowntimeForm::TYPE_FIXED,
'hours' => '',
'minutes' => '',
'childobjects' => '4',
)
);
$form->setWithChildren(false);
$form->setCurrentDowntimes(array('foo'));
$this->assertFalse(
$form->isSubmittedAndValid(),
'Assert and incorrect (numeric) childobjects value to cause validation errors'
);
}
public function testTimeRange()
{
$form = $this->createForm(self::FORM_CLASS);
$form->setCurrentDowntimes(array('foo'));
$form->buildForm();
$time1 = $form->getElement('starttime')->getValue();
$time2 = $form->getElement('endtime')->getValue();
$this->assertEquals(3600, ($time2 - $time1));
}
}

View File

@ -1,117 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Module\Monitoring\Application\Forms\Command;
use Icinga\Test\BaseTestCase;
use Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm;
class SubmitPassiveCheckResultFormTest extends BaseTestCase
{
const FORM_CLASS = 'Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm';
public function testStateTypes()
{
$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'
);
$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'
);
}
/**
* @expectedException Icinga\Exception\ProgrammingError
* @expectedExceptionMessage Type is not valid
*/
public function testMissingTypeThrowingException()
{
$form = $this->createForm(self::FORM_CLASS, array());
$form->buildForm();
}
public function testCorrectFormCreation()
{
$form = $this->createForm(self::FORM_CLASS, array());
$form->setType(SubmitPassiveCheckResultForm::TYPE_SERVICE);
$form->buildForm();
}
public function testCorrectServicePassiveCheckSubmission()
{
$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'
);
}
public function testIncorrectCheckoutputRecognition()
{
$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 '
);
}
public function testIncorrectStateRecognition()
{
$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'
);
}
}