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()
191
191
$ this ->assertRequiredValidationErrorMessage ($ input );
192
192
}
193
193
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
+
194
207
/**
195
208
* @group 28
196
209
* @group 60
@@ -208,6 +221,24 @@ public function testRequiredWithoutFallbackAndValueNotSetProvidesNotEmptyValidat
208
221
$ this ->assertRequiredValidationErrorMessage ($ input );
209
222
}
210
223
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
+
211
242
public function testNotRequiredWithoutFallbackAndValueNotSetThenIsValid ()
212
243
{
213
244
$ input = $ this ->input ;
You can’t perform that action at this time.
0 commit comments