Simple Test Failures

indytechcook - September 10, 2009 - 00:25
Project:ImageField
Version:6.x-3.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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:

<?php
   
// 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.

<?php
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.

<?php
 
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

#1

indytechcook - September 10, 2009 - 00:26
Status:active» needs review

Attaching Patch against HEAD.

AttachmentSize
imagefield-573224.patch 687 bytes

#2

quicksketch - October 20, 2009 - 20:02
Status:needs review» fixed

Thanks, committed.

#3

System Message - November 3, 2009 - 20:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.