@@ -113,22 +113,6 @@ public function testCanRetrieveRawValue()
113113 $ this ->assertEquals ($ value , $ this ->input ->getRawValue ());
114114 }
115115
116- public function testIsValidReturnsFalseIfValidationChainFails ()
117- {
118- $ this ->input ->setValue (['tmp_name ' => 'bar ' ]);
119- $ validator = new Validator \Digits ();
120- $ this ->input ->getValidatorChain ()->attach ($ validator );
121- $ this ->assertFalse ($ this ->input ->isValid ());
122- }
123-
124- public function testIsValidReturnsTrueIfValidationChainSucceeds ()
125- {
126- $ this ->input ->setValue (['tmp_name ' => 'bar ' ]);
127- $ validator = new Validator \NotEmpty ();
128- $ this ->input ->getValidatorChain ()->attach ($ validator );
129- $ this ->assertTrue ($ this ->input ->isValid ());
130- }
131-
132116 public function testValidationOperatesOnFilteredValue ()
133117 {
134118 $ this ->markTestSkipped ('Test is not enabled in FileInputTest ' );
@@ -421,58 +405,64 @@ public function testIsEmptyFileMultiFileOk()
421405 $ this ->assertFalse ($ this ->input ->isEmptyFile ($ rawValue ));
422406 }
423407
424- public function emptyValuesProvider ()
408+ public function testNotAllowEmptyWithFilterConvertsNonemptyToEmptyIsNotValid ()
425409 {
426- // Provide empty values specific for file input
427- return [
428- ['file ' ],
429- [[
430- 'tmp_name ' => '' ,
431- 'error ' => \UPLOAD_ERR_NO_FILE ,
432- ]],
433- [[[
434- 'tmp_name ' => 'foo ' ,
435- 'error ' => \UPLOAD_ERR_NO_FILE
436- ]]],
437- ];
410+ $ this ->markTestSkipped ('does not apply to FileInput ' );
438411 }
439412
440- /**
441- * @dataProvider emptyValuesProvider
442- */
443- public function testAllowEmptyOptionSet ($ emptyValue )
413+ public function testNotAllowEmptyWithFilterConvertsEmptyToNonEmptyIsValid ()
444414 {
445- // UploadFile validator is disabled, pretend one
446- $ validator = new Validator \Callback (function () {
447- return false ; // This should never be called
448- });
449- $ this ->input ->getValidatorChain ()->attach ($ validator );
450- parent ::testAllowEmptyOptionSet ($ emptyValue );
415+ $ this ->markTestSkipped ('does not apply to FileInput ' );
451416 }
452417
453- /**
454- * @dataProvider emptyValuesProvider
455- */
456- public function testAllowEmptyOptionNotSet ($ emptyValue )
457- {
458- // UploadFile validator is disabled, pretend one
459- $ message = 'pretend failing UploadFile validator ' ;
460- $ validator = new Validator \Callback (function () {
461- return false ;
462- });
463- $ validator ->setMessage ($ message );
464- $ this ->input ->getValidatorChain ()->attach ($ validator );
465- parent ::testAllowEmptyOptionNotSet ($ emptyValue );
466- $ this ->assertEquals (['callbackValue ' => $ message ], $ this ->input ->getMessages ());
467- }
468418
469- public function testNotAllowEmptyWithFilterConvertsNonemptyToEmptyIsNotValid ()
419+ public function isRequiredVsAllowEmptyVsContinueIfEmptyVsIsValidProvider ()
470420 {
471- $ this ->markTestSkipped ('does not apply to FileInput ' );
421+ $ dataSets = parent ::isRequiredVsAllowEmptyVsContinueIfEmptyVsIsValidProvider ();
422+
423+ // FileInput do not use NotEmpty validator so the only validator present in the chain is the custom one.
424+ unset($ dataSets ['Required: T; AEmpty: F; CIEmpty: F; Validator: X / tmp_name ' ]);
425+ unset($ dataSets ['Required: T; AEmpty: F; CIEmpty: F; Validator: X / single ' ]);
426+ unset($ dataSets ['Required: T; AEmpty: F; CIEmpty: F; Validator: X / multi ' ]);
427+
428+ return $ dataSets ;
472429 }
473430
474- public function testNotAllowEmptyWithFilterConvertsEmptyToNonEmptyIsValid ()
431+ public function emptyValueProvider ()
475432 {
476- $ this ->markTestSkipped ('does not apply to FileInput ' );
433+ return [
434+ 'tmp_name ' => [
435+ 'raw ' => 'file ' ,
436+ 'filtered ' => [
437+ 'tmp_name ' => 'file ' ,
438+ 'name ' => 'file ' ,
439+ 'size ' => 0 ,
440+ 'type ' => '' ,
441+ 'error ' => UPLOAD_ERR_NO_FILE ,
442+ ],
443+ ],
444+ 'single ' => [
445+ 'raw ' => [
446+ 'tmp_name ' => '' ,
447+ 'error ' => UPLOAD_ERR_NO_FILE ,
448+ ],
449+ 'filtered ' => [
450+ 'tmp_name ' => '' ,
451+ 'error ' => UPLOAD_ERR_NO_FILE ,
452+ ],
453+ ],
454+ 'multi ' => [
455+ 'raw ' => [
456+ [
457+ 'tmp_name ' => 'foo ' ,
458+ 'error ' => UPLOAD_ERR_NO_FILE ,
459+ ],
460+ ],
461+ 'filtered ' => [
462+ 'tmp_name ' => 'foo ' ,
463+ 'error ' => UPLOAD_ERR_NO_FILE ,
464+ ],
465+ ],
466+ ];
477467 }
478468}
0 commit comments