|
|
@@ -61,20 +61,22 @@ class Zend_Validate_File_ExcludeMimeTypeTest extends PHPUnit_Framework_TestCase
|
|
|
public function testBasic()
|
|
|
{
|
|
|
$valuesExpected = array(
|
|
|
- array('image/gif', false),
|
|
|
+ array('image/gif', true),
|
|
|
+ array('image/jpeg', false),
|
|
|
array('image', false),
|
|
|
array('test/notype', true),
|
|
|
array('image/gif, image/jpeg', false),
|
|
|
- array(array('image/vasa', 'image/gif'), false),
|
|
|
- array(array('image/jpeg', 'gif'), false),
|
|
|
- array(array('image/jpeg', 'jpeg'), true),
|
|
|
+ array(array('image/vasa', 'image/jpeg'), false),
|
|
|
+ array(array('image/gif', 'jpeg'), false),
|
|
|
+ array(array('image/gif', 'gif'), true),
|
|
|
);
|
|
|
|
|
|
+ $filetest = dirname(__FILE__) . '/_files/picture.jpg';
|
|
|
$files = array(
|
|
|
- 'name' => 'testsize.mo',
|
|
|
- 'type' => 'image/gif',
|
|
|
+ 'name' => 'picture.jpg',
|
|
|
+ 'type' => 'image/jpeg',
|
|
|
'size' => 200,
|
|
|
- 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo',
|
|
|
+ 'tmp_name' => $filetest,
|
|
|
'error' => 0
|
|
|
);
|
|
|
|
|
|
@@ -83,7 +85,7 @@ class Zend_Validate_File_ExcludeMimeTypeTest extends PHPUnit_Framework_TestCase
|
|
|
$validator->enableHeaderCheck();
|
|
|
$this->assertEquals(
|
|
|
$element[1],
|
|
|
- $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files),
|
|
|
+ $validator->isValid($filetest, $files),
|
|
|
"Tested with " . var_export($element, 1)
|
|
|
);
|
|
|
}
|
|
|
@@ -151,6 +153,21 @@ class Zend_Validate_File_ExcludeMimeTypeTest extends PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType());
|
|
|
$this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Ensure validator is not affected by PHP bug #63976
|
|
|
+ */
|
|
|
+ public function testShouldHaveProperErrorMessageOnNotReadableFile()
|
|
|
+ {
|
|
|
+ $validator = new Zend_Validate_File_ExcludeMimeType('image/jpeg');
|
|
|
+
|
|
|
+ $this->assertFalse($validator->isValid('notexisting'), array('name' => 'notexisting'));
|
|
|
+ $this->assertEquals(
|
|
|
+ array('fileExcludeMimeTypeNotReadable' => "File 'notexisting' is not readable or does not exist"),
|
|
|
+ $validator->getMessages()
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Call Zend_Validate_File_ExcludeMimeTypeTest::main() if this source file is executed directly.
|