diff --git a/test/InputTest.php b/test/InputTest.php index 2f99d8d8..96c3582c 100644 --- a/test/InputTest.php +++ b/test/InputTest.php @@ -191,6 +191,19 @@ public function testRequiredWithoutFallbackAndValueNotSetThenFail() $this->assertRequiredValidationErrorMessage($input); } + public function testRequiredWithoutFallbackAndValueNotSetThenFailReturnsCustomErrorMessageWhenSet() + { + $input = $this->input; + $input->setRequired(true); + $input->setErrorMessage('FAILED TO VALIDATE'); + + $this->assertFalse( + $input->isValid(), + 'isValid() should be return always false when no fallback value, is required, and not data is set.' + ); + $this->assertSame(['FAILED TO VALIDATE'], $input->getMessages()); + } + /** * @group 28 * @group 60 @@ -208,6 +221,24 @@ public function testRequiredWithoutFallbackAndValueNotSetProvidesNotEmptyValidat $this->assertRequiredValidationErrorMessage($input); } + /** + * @group 28 + * @group 60 + */ + public function testRequiredWithoutFallbackAndValueNotSetProvidesCustomErrorMessageWhenSet() + { + $input = $this->input; + $input->setRequired(true); + $input->setErrorMessage('FAILED TO VALIDATE'); + + $this->assertFalse( + $input->isValid(), + 'isValid() should always return false when no fallback value is present, ' + . 'the input is required, and no data is set.' + ); + $this->assertSame(['FAILED TO VALIDATE'], $input->getMessages()); + } + public function testNotRequiredWithoutFallbackAndValueNotSetThenIsValid() { $input = $this->input;