1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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.
This commit is contained in:
Christoph M. Becker
2024-12-25 23:15:45 +01:00
committed by GitHub
parent 1331444822
commit c1c6520c4f
2 changed files with 3 additions and 5 deletions

View File

@@ -14,10 +14,8 @@ imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
imageline($im, 10,10, 89,89, $white);
// write the md5 hash of its BMP representation
ob_start();
imagebmp($im);
echo md5(ob_get_clean());
require __DIR__ . "/func.inc";
test_image_equals_file(__DIR__ . "/imagebmp_basic.png", $im);
?>
--EXPECT--
d49124076771822b09fa72e168c0de56
The images are equal.

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B