Commit 894255af authored by quicksketch's avatar quicksketch

#659648: Fixes for SimpleTests. Test for file extention validation fails.

parent 0b168c78
......@@ -52,7 +52,7 @@ function field_file_load($fid, $reset = NULL) {
// Cast to an array for the field storage.
// Contrary to fields, hook_file() and core file functions expect objects.
return (array)$files[$fid];
return isset($files[$fid]) ? (array) $files[$fid] : FALSE;
}
/**
......
......@@ -748,8 +748,8 @@ function filefield_validate_size_help($size) {
function filefield_validate_image_resolution(&$file, $maximum_dimensions = 0, $minimum_dimensions = 0) {
$errors = array();
list($max_width, $max_height) = explode('x', $maximum_dimensions);
list($min_width, $min_height) = explode('x', $minimum_dimensions);
@list($max_width, $max_height) = explode('x', $maximum_dimensions);
@list($min_width, $min_height) = explode('x', $minimum_dimensions);
// Check first that the file is an image.
if ($info = image_get_info($file->filepath)) {
......
......@@ -476,8 +476,10 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
// Setup files for extension checking.
$test_file = $this->getTestFile('image');
preg_match('/(?<=\.)[^\.]*$/', $test_file->filename, $matches);
$extention = current($matches);
$wrong_extension_file = drupal_clone($test_file);
$wrong_extension_file->filename = str_replace('.png', '.jpg', $test_file->filename);
$wrong_extension_file->filename = str_replace(".$extention", '.jpg', $test_file->filename);
$wrong_extension_file->filepath = file_directory_path() .'/'. $wrong_extension_file->filename;
$original_path = $test_file->filepath;
file_copy($original_path, $wrong_extension_file->filepath);
......@@ -492,7 +494,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with no extension checking.'));
// Enable extension checking.
$this->updateFileField($field['field_name'], $type->name, array(), array('file_extensions' => 'txt png jpg'));
$this->updateFileField($field['field_name'], $type->name, array(), array('file_extensions' => "txt png jpg $extention"));
// Check that the file can be uploaded with extension checking.
$nid = $this->uploadNodeFile($test_file, $field['field_name'], $type->name);
......
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