Skip to content

Commit c1c6520

Browse files
authored
Make imagebmp_basic.phpt more resilient (GH-17265)
Checking for the exact output of most image formats is brittle; even an otherwise change to some header field causes the output to change, even if the image would be visually identical. Checking for an (MD5) hash is even worse, since if the tests fails, we have no clue for what reason. Thus we compare the generated image against an pre-generated PNG, using a test helper which will output a simple image diff in case of test failure.
1 parent 1331444 commit c1c6520

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

ext/gd/tests/imagebmp_basic.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ imagecolorallocate($im, 0, 0, 0);
1414
$white = imagecolorallocate($im, 255, 255, 255);
1515
imageline($im, 10,10, 89,89, $white);
1616

17-
// write the md5 hash of its BMP representation
18-
ob_start();
19-
imagebmp($im);
20-
echo md5(ob_get_clean());
17+
require __DIR__ . "/func.inc";
18+
test_image_equals_file(__DIR__ . "/imagebmp_basic.png", $im);
2119
?>
2220
--EXPECT--
23-
d49124076771822b09fa72e168c0de56
21+
The images are equal.

ext/gd/tests/imagebmp_basic.png

141 Bytes
Loading

0 commit comments

Comments
 (0)