Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 6724a21

Browse files
committed
Merge branch 'hotfix/custom-error-message' into develop
Forward port #63
2 parents f9441e5 + 6845085 commit 6724a21

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/InputTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ public function testRequiredWithoutFallbackAndValueNotSetThenFail()
191191
$this->assertRequiredValidationErrorMessage($input);
192192
}
193193

194+
public function testRequiredWithoutFallbackAndValueNotSetThenFailReturnsCustomErrorMessageWhenSet()
195+
{
196+
$input = $this->input;
197+
$input->setRequired(true);
198+
$input->setErrorMessage('FAILED TO VALIDATE');
199+
200+
$this->assertFalse(
201+
$input->isValid(),
202+
'isValid() should be return always false when no fallback value, is required, and not data is set.'
203+
);
204+
$this->assertSame(['FAILED TO VALIDATE'], $input->getMessages());
205+
}
206+
194207
/**
195208
* @group 28
196209
* @group 60
@@ -208,6 +221,24 @@ public function testRequiredWithoutFallbackAndValueNotSetProvidesNotEmptyValidat
208221
$this->assertRequiredValidationErrorMessage($input);
209222
}
210223

224+
/**
225+
* @group 28
226+
* @group 60
227+
*/
228+
public function testRequiredWithoutFallbackAndValueNotSetProvidesCustomErrorMessageWhenSet()
229+
{
230+
$input = $this->input;
231+
$input->setRequired(true);
232+
$input->setErrorMessage('FAILED TO VALIDATE');
233+
234+
$this->assertFalse(
235+
$input->isValid(),
236+
'isValid() should always return false when no fallback value is present, '
237+
. 'the input is required, and no data is set.'
238+
);
239+
$this->assertSame(['FAILED TO VALIDATE'], $input->getMessages());
240+
}
241+
211242
public function testNotRequiredWithoutFallbackAndValueNotSetThenIsValid()
212243
{
213244
$input = $this->input;

0 commit comments

Comments
 (0)