Skip to content

Commit

Permalink
Merge branch 'hotfix/custom-error-message'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Sep 3, 2015
2 parents 873327f + 6845085 commit f0ca63f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit f0ca63f

Please sign in to comment.