When you run simple test against imagefield you get several errors. In my case, many were caused by the simple test files not being copied to my sites\\files folder. This is fixed by this patch to the simple test module: #568526: file directory location

The last 3 failures were caused by the imagefield test script getting the improper file in the "ImageField validation" test script. It calls the following function in the testResolution functino on line 161:

    // Get our test file (PNG, 360x240).
    $test_file = $this->getTestFile('image');

The problem is that when simpletest returns the list of image files, it sorts them by file size.

protected function drupalGetTestFiles($type, $size = NULL) {
  $files = array();
.
.
.

  usort($files, array($this, 'drupalCompareFiles'));
  return $files;
}

The smallest file is "image-test.gif" @183 bytes (40px x 20px). This is a much less then what is required by the script (PNG @ 360x240). The needed file is called "image-1.png" which is the first image file by name.

Luckly for us "getTestFile" has another parameter, size! Since we know that the size of the image-1.png file is 64027 bytes, then we can add this to the test script.

  function testResolution() {
    $type = $this->node_type;
    $field = $this->field;

    // Get our test file (PNG, 360x240).
    $test_file = $this->getTestFile('image', 64027);
    $test_image_info = image_get_info($test_file->filepath);
    $width = $test_image_info['width'];
    $height = $test_image_info['height'];
.
.
.
}

Cheers!
Neil

CommentFileSizeAuthor
#1 imagefield-573224.patch687 bytesindytechcook

Comments

indytechcook’s picture

Status: Active » Needs review
StatusFileSize
new687 bytes

Attaching Patch against HEAD.

quicksketch’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.