Commit 80094f1c authored by quicksketch's avatar quicksketch

Fixing MIME Detect test to use binary file if possible.

parent f8a5bd87
......@@ -526,7 +526,21 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.'));
// Check that a mismatched extension cannot be uploaded.
$mimedetect = FALSE;
if (module_exists('mimedetect')) {
$mimedetect = TRUE;
module_load_include('install', 'mimedetect');
if (!extension_loaded('fileinfo')) {
variable_set('mimedetect_enable_file_binary', 1);
$requirements = mimedetect_requirements('runtime');
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$mimedetect = FALSE;
if ($mimedetect) {
$this->uploadNodeFile($wrong_extension_file, $field, $type->name);
$error_pattern = "/The file contents \([a-z\-\/]+\) do not match its extension \([a-z]+\)\./";
$this->assertPattern($error_pattern, t('File prevented from uploading because its extension does not match its content.'));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment