Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 01e455c

Browse files
committed
ExcludeMimeType tests - error messages in data provider
1 parent 239be0f commit 01e455c

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

test/File/ExcludeMimeTypeTest.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)