This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments