@@ -25,17 +25,21 @@ public function basicBehaviorDataProvider()
2525 {
2626 $ testFile = __DIR__ . '/_files/picture.jpg ' ;
2727 $ fileUpload = [
28- 'tmp_name ' => $ testFile , 'name ' => basename ($ testFile ),
29- 'size ' => 200 , 'error ' => 0 , 'type ' => 'image/jpeg '
28+ 'tmp_name ' => $ testFile ,
29+ 'name ' => basename ($ testFile ),
30+ 'size ' => 200 ,
31+ 'error ' => 0 ,
32+ 'type ' => 'image/jpeg ' ,
3033 ];
34+
3135 return [
32- // Options, isValid Param, Expected value
33- ['image/gif ' , $ fileUpload , true ],
34- ['image ' , $ fileUpload , false ],
35- ['test/notype ' , $ fileUpload , true ],
36- ['image/gif, image/jpeg ' , $ fileUpload , false ],
36+ // Options, isValid Param, Expected value, messages
37+ ['image/gif ' , $ fileUpload , true ],
38+ ['image ' , $ fileUpload , false , [ExcludeMimeType:: FALSE_TYPE => " File has an incorrect mimetype of 'image/jpeg' " ] ],
39+ ['test/notype ' , $ fileUpload , true ],
40+ ['image/gif, image/jpeg ' , $ fileUpload , false , [ExcludeMimeType:: FALSE_TYPE => " File has an incorrect mimetype of 'image/jpeg' " ] ],
3741 [['image/vasa ' , 'image/gif ' ], $ fileUpload , true ],
38- [['image/gif ' , 'jpeg ' ], $ fileUpload , false ],
42+ [['image/gif ' , 'jpeg ' ], $ fileUpload , false , [ExcludeMimeType:: FALSE_TYPE => " File has an incorrect mimetype of 'image/jpeg' " ] ],
3943 [['image/gif ' , 'gif ' ], $ fileUpload , true ],
4044 ];
4145 }
@@ -44,17 +48,18 @@ public function basicBehaviorDataProvider()
4448 * Ensures that the validator follows expected behavior
4549 *
4650 * @dataProvider basicBehaviorDataProvider
47- * @return void
51+ *
52+ * @param string|array $options
53+ * @param array $isValidParam
54+ * @param bool $expected
55+ * @param array $messages
4856 */
49- public function testBasic ($ options , $ isValidParam , $ expected )
57+ public function testBasic ($ options , array $ isValidParam , $ expected, array $ messages = [] )
5058 {
5159 $ validator = new ExcludeMimeType ($ options );
5260 $ validator ->enableHeaderCheck ();
5361 $ this ->assertEquals ($ expected , $ validator ->isValid ($ isValidParam ));
54- if (!$ expected ) {
55- $ this ->assertArrayHasKey ($ validator ::FALSE_TYPE , $ validator ->getMessages ());
56- $ this ->assertNotEmpty ($ validator ->getMessages ()[$ validator ::FALSE_TYPE ]);
57- }
62+ $ this ->assertEquals ($ messages , $ validator ->getMessages ());
5863 }
5964
6065 /**
0 commit comments