@@ -25,17 +25,21 @@ public function basicBehaviorDataProvider()
25
25
{
26
26
$ testFile = __DIR__ . '/_files/picture.jpg ' ;
27
27
$ 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 ' ,
30
33
];
34
+
31
35
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' " ] ],
37
41
[['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' " ] ],
39
43
[['image/gif ' , 'gif ' ], $ fileUpload , true ],
40
44
];
41
45
}
@@ -44,17 +48,18 @@ public function basicBehaviorDataProvider()
44
48
* Ensures that the validator follows expected behavior
45
49
*
46
50
* @dataProvider basicBehaviorDataProvider
47
- * @return void
51
+ *
52
+ * @param string|array $options
53
+ * @param array $isValidParam
54
+ * @param bool $expected
55
+ * @param array $messages
48
56
*/
49
- public function testBasic ($ options , $ isValidParam , $ expected )
57
+ public function testBasic ($ options , array $ isValidParam , $ expected, array $ messages = [] )
50
58
{
51
59
$ validator = new ExcludeMimeType ($ options );
52
60
$ validator ->enableHeaderCheck ();
53
61
$ 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 ());
58
63
}
59
64
60
65
/**
0 commit comments