diff --git a/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php b/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php index 6580a9b25..9f3687919 100644 --- a/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/CustomNotificationFormTest.php @@ -8,11 +8,11 @@ namespace Test\Monitoring\Forms\Command; require_once realpath(__DIR__ . '/BaseFormTest.php'); require_once realpath(__DIR__ . '/../../../../../application/forms/Command/CustomNotificationForm.php'); -use \Monitoring\Form\Command\CustomNotificationForm; // Used by constant FORMCLASS +use \Monitoring\Form\Command\CustomNotificationForm; // Used by constant FORM_CLASS class CustomNotificationFormTest extends BaseFormTest { - const FORMCLASS = 'Monitoring\Form\Command\CustomNotificationForm'; + const FORM_CLASS = 'Monitoring\Form\Command\CustomNotificationForm'; public function testFormInvalidWhenCommentMissing() { @@ -20,7 +20,7 @@ class CustomNotificationFormTest extends BaseFormTest 'author' => 'Author', 'comment' => '', 'btn_submit' => 'Submit' - ), self::FORMCLASS); + ), self::FORM_CLASS); $this->assertFalse( $form->isSubmittedAndValid(), diff --git a/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php b/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php index 24abc39f3..2891bfef5 100644 --- a/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php +++ b/modules/monitoring/test/php/application/forms/Command/DelayNotificationFormTest.php @@ -1,57 +1,58 @@ getRequestForm(array( - 'minutes' => 12, - 'btn_submit' => 'foo' - ), 'Monitoring\Form\Command\DelayNotificationForm'); - - $form->buildForm(); - $this->assertCount(5, $form->getElements()); - - $element = $form->getElement('minutes'); - $this->assertInstanceOf('Zend_Form_Element_Text', $element); - $this->assertEquals('0', $element->getValue(), "Assert a correct default value in minutes"); - $this->assertTrue($element->isRequired(), "Assert minutes to be declared as required"); - - $this->assertTrue( - $form->isSubmittedAndValid(), - "Assert a correct DelayNotificationForm to be considered valid" - ); - - $this->assertEquals('12', $form->getValue('minutes'), "Assert the minutes field to be correctly populated"); - } - - public function testInvalidMinuteValue() - { - $form = $this->getRequestForm(array( - 'minutes' => 'SCHAHH-LAHH-LAHH', - 'btn_submit' => 'foo' - ), 'Monitoring\Form\Command\DelayNotificationForm'); - - $form->buildForm(); + 'minutes' => '', + 'btn_submit' => 'Submit' + ), self::FORM_CLASS); $this->assertFalse( $form->isSubmittedAndValid(), - "Asserting invalid minutes (NaN) to cause validation errors" + 'Missing notification delay must be considered invalid' ); + } - $errors = $form->getErrors('minutes'); - $this->assertCount(1, $errors, "Asserting an error to be added when the minutes value is invalid"); - $this->assertEquals('notBetween', $errors[0], "Assert correct error message"); + public function testFormInvalidWhenNotificationDelayNaN() + { + $form = $this->getRequestForm(array( + 'minutes' => 'A String', + 'btn_submit' => 'Submit' + ), self::FORM_CLASS); + + $this->assertFalse( + $form->isSubmittedAndValid(), + 'Incorrect notification delay, i.e. NaN must be considered invalid' + ); + } + + public function testFormInvalidWhenNotificationDelayOverflows() + { + $form = $this->getRequestForm(array( + 'minutes' => DelayNotificationForm::MAX_DELAY + 1, + 'btn_submit' => 'Submit' + ), self::FORM_CLASS); + + $this->assertFalse( + $form->isSubmittedAndValid(), + 'Notification delay bigger than constant "DelayNotificationForm::MAX_DELAY" must be considered invalid' + ); } } +// @codingStandardsIgnoreEnd