Skip to content

Commit a3159d2

Browse files
committed
Make tests a little more resilient
PNG allows identical images to be stored differently what makes nearly all tests checking the MD5 hash of the PNG representation fail with external libgd. For now, we use the GD format instead, which doesn't allow for such differences. Of course, this md5() checking should be replaced by a image diffing feature in the long run.
1 parent 48198e4 commit a3159d2

30 files changed

+60
-60
lines changed

ext/gd/tests/bug22544.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Bug #22544 (TrueColor transparency in PNG images).
1515
$red = imageColorAllocate($image, 255, 50, 50);
1616
imageColorTransparent($image, $transparent);
1717
imageFilledRectangle($image, 0, 0, 640-1, 100-1, $transparent);
18-
imagePng($image, $dest);
18+
imagegd($image, $dest);
1919
echo md5_file($dest) . "\n";
2020
@unlink($dest);
2121
?>
2222
--EXPECT--
23-
10a57d09a2c63fad87b85b38d6b258d6
23+
7643ef115f642a79c2de6e411f485ddd

ext/gd/tests/bug43828.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ $color = imagecolorallocatealpha($im, 0, 255, 0, 100);
1515
imagefilledarc($im, 49, 49, 99,99, 0 , 360, $color, IMG_ARC_PIE);
1616

1717
ob_start();
18-
imagepng($im);
18+
imagegd($im);
1919
echo md5(ob_get_clean());
2020
imagedestroy($im);
2121
?>
2222
--EXPECT--
23-
3d82e4525f19790ae1055366e2a36917
23+
2400a58cd7570b5472c25264715321cd

ext/gd/tests/bug72604.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ $im = imagecreatetruecolor(100, 100);
1111
imagesetthickness($im, 5);
1212
imagearc($im, 50, 50, 90, 90, 0, 360, 0xffffff);
1313
ob_start();
14-
imagepng($im);
14+
imagegd($im);
1515
$imagestring = ob_get_clean();
1616
echo md5($imagestring);
1717
?>
1818
--EXPECT--
19-
2ffa6afb915afbdf870cf6459477bc8a
19+
4f5080080a774efe4fc8d55cd4a5849c

ext/gd/tests/imagearc_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagearc($image, 50, 50, 30, 30, 0, 180, $white);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
f18ad8001afefee2e9b8c08d6884425b
28+
13149c3fd54a92a0d43cd5083a19b1d7

ext/gd/tests/imagearc_error1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagearc($image, 50, 50, 30, 30, 0, 180);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECTF--
2828
Warning: imagearc() expects exactly 8 parameters, 7 given in %s on line %d
29-
abebb25b5a2813cfbf92f1f24365786a
29+
c5b7013900f5466aebfc42499a7ec8ec

ext/gd/tests/imagearc_variation1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagearc($image, 50, 50, 30, 30, 0, -90, $white);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
ed2c8427a9922dfd8a105f10a88a0d20
28+
fe662ebe7488057c43e38c5de43b1727

ext/gd/tests/imagearc_variation2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagearc($image, 50, 50, 30, 30, -90, 0, $white);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
463b4aea9d9acfab30016ee92613c779
28+
8bd78aa775b5f29e7227eaeebaa84889

ext/gd/tests/imagechar_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ $white = imagecolorallocate($image, 255,255,255);
1515
$result = imagechar($image, 1, 5, 5, 'C', $white);
1616

1717
ob_start();
18-
imagepng($image, null, 9);
18+
imagegd($image);
1919
$img = ob_get_contents();
2020
ob_end_clean();
2121

2222
echo md5(base64_encode($img));
2323
?>
2424
--EXPECT--
25-
e94962ac28ad03bd4142cb1abe9ef98b
25+
f0291252e7ac2fadda25e63287e6860c

ext/gd/tests/imagecharup_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ $white = imagecolorallocate($image, 255,255,255);
1515
$result = imagecharup($image, 1, 5, 5, 'C', $white);
1616

1717
ob_start();
18-
imagepng($image, null, 9);
18+
imagegd($image);
1919
$img = ob_get_contents();
2020
ob_end_clean();
2121

2222
echo md5(base64_encode($img));
2323
?>
2424
--EXPECT--
25-
79b48d5cef6d489bb68573df0296d775
25+
c65aad5d78f934dee2a844e7978eabd5

ext/gd/tests/imagecolorallocatealpha_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ $half = imagefilledarc ( $img, 75, 75, 70, 70, 0, 180, $cor, IMG_ARC_PIE );
1818
$half2 = imagefilledarc ( $img, 75, 75, 70, 70, 180, 360, $corA, IMG_ARC_PIE );
1919

2020
ob_start();
21-
imagepng($img, null, 9);
21+
imagegd($img);
2222
$imgsrc = ob_get_contents();
2323
ob_end_clean();
2424

2525
var_dump(md5(base64_encode($imgsrc)));
2626
var_dump($corA);
2727
?>
2828
--EXPECT--
29-
string(32) "f95489d97f4f1a5c4dc265388922d1ec"
29+
string(32) "0981ef94ee2209a8dccb59aa8ad07e18"
3030
int(842163455)

ext/gd/tests/imagecolorset_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ imagecolorset($im, $bg, 0, 0, 255);
2525

2626
// Get output and generate md5 hash
2727
ob_start();
28-
imagepng($im, null, 9);
28+
imagegd($im);
2929
$result_image = ob_get_contents();
3030
ob_end_clean();
3131
echo md5(base64_encode($result_image));
3232
imagedestroy($im);
3333
?>
3434
--EXPECT--
35-
6f2002aafb57b2d275fad6a6258d7476
35+
85e406abd0a975c97b3403cad5d078c9

ext/gd/tests/imageconvolution_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ $gaussian = array(
2323
imageconvolution($image, $gaussian, 16, 0);
2424

2525
ob_start();
26-
imagepng($image, null, 9);
26+
imagegd($image);
2727
$img = ob_get_contents();
2828
ob_end_clean();
2929

3030
echo md5(base64_encode($img));
3131
?>
3232
--EXPECT--
33-
594576a2a2a689447ffc07eb5a73f09b
33+
20979b45f8772cdbd78262af4e332638

ext/gd/tests/imagecreatetruecolor_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
1212
$image = imagecreatetruecolor(180, 30);
1313

1414
ob_start();
15-
imagepng($image, null, 9);
15+
imagegd($image);
1616
$img = ob_get_contents();
1717
ob_end_clean();
1818

1919
echo md5(base64_encode($img));
2020
?>
2121
--EXPECT--
22-
5a8fe9864cbd20e5dbe730c77f30db95
22+
da884f488a851e0267a316ad232aee86

ext/gd/tests/imageellipse_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ $image = imagecreatetruecolor(400, 300);
1717
imageellipse($image, 200, 150, 300, 200, 16777215);
1818

1919
ob_start();
20-
imagepng($image, null, 9);
20+
imagegd($image);
2121
$img = ob_get_contents();
2222
ob_end_clean();
2323

2424
echo md5(base64_encode($img));
2525
?>
2626
--EXPECT--
27-
d8b9bc2ca224bd68569413f4617f8e1f
27+
49c1544b012c3460c74cd04f1332d4ad

ext/gd/tests/imagefilledarc_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagefilledarc($image, 50, 50, 30, 30, 0, 90, $white, IMG_ARC_PIE);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
beffeaf5231adaaff1f21a2108fb6f7e
28+
87637c60ac0ceea48dbcaa4d98319f90

ext/gd/tests/imagefilledarc_error1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagefilledarc($image, 50, 50, 30, 30, 0, 90, $white);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECTF--
2828
Warning: imagefilledarc() expects exactly 9 parameters, 8 given in %s on line %d
29-
abebb25b5a2813cfbf92f1f24365786a
29+
c5b7013900f5466aebfc42499a7ec8ec

ext/gd/tests/imagefilledarc_variation1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagefilledarc($image, 50, 50, 30, 30, 0, -25, $white, IMG_ARC_PIE);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
b467492b806001c3720b3f18cfbde5b0
28+
f25f589b5c5fa7deead7242652919bcf

ext/gd/tests/imagefilledarc_variation2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1818
imagefilledarc($image, 50, 50, 30, 30, -25, 25, $white, IMG_ARC_PIE);
1919

2020
ob_start();
21-
imagepng($image);
21+
imagegd($image);
2222
$img = ob_get_contents();
2323
ob_end_clean();
2424

2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
cfad369fc6d863785d3c95b4b4788225
28+
43c2973eb4872903eb6f5464c7965a93

ext/gd/tests/imagefilledellipse_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
1515
imagefilledellipse($image, 50, 50, 40, 30, $white);
1616

1717
ob_start();
18-
imagepng($image);
18+
imagegd($image);
1919
$img = ob_get_contents();
2020
ob_end_clean();
2121

2222
echo md5(base64_encode($img));
2323
?>
2424
--EXPECT--
25-
9ba540bba1b78c9f08efaa6fa0afd93b
25+
233beffe003a41d3c9e788039e3191dd

ext/gd/tests/imagefilltoborder_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) );
2222
imagefilltoborder( $image, 50, 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) );
2323

2424
ob_start();
25-
imagepng( $image, null, 9 );
25+
imagegd( $image);
2626
$img = ob_get_contents();
2727
ob_end_clean();
2828

2929
echo md5(base64_encode($img));
3030

3131
?>
3232
--EXPECT--
33-
847ec236f1c4d14c465306c8408550fc
33+
8185a06ccff03c2abeb99d5e3ed60e45

ext/gd/tests/imagegammacorrect_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ $gamma = imagegammacorrect($image, 1, 5);
2121

2222
if ($gamma){
2323
ob_start();
24-
imagepng($image, null, 9);
24+
imagegd($image);
2525
$img = ob_get_contents();
2626
ob_end_clean();
2727
}
2828

2929
echo md5(base64_encode($img));
3030
?>
3131
--EXPECT--
32-
e79553115df689ea5df18a4636380569
32+
1f625723f9d27251a1f15b83a6a4bf55

ext/gd/tests/imagegammacorrect_variation1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ $gamma = imagegammacorrect($image, 1, 5);
2121

2222
if ($gamma){
2323
ob_start();
24-
imagepng($image, null, 9);
24+
imagegd($image);
2525
$img = ob_get_contents();
2626
ob_end_clean();
2727
}
2828

2929
echo md5(base64_encode($img));
3030
?>
3131
--EXPECT--
32-
b017b1ddc8bda00e82aa8cbfb54c35d4
32+
32fdb7b3675e4a9fd601c6a0645c88b3

ext/gd/tests/imagelayereffect_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ $layer = imagelayereffect($image, IMG_EFFECT_REPLACE);
1616

1717
if ($layer){
1818
ob_start();
19-
imagepng($image, null, 9);
19+
imagegd($image);
2020
$img = ob_get_contents();
2121
ob_end_clean();
2222
}
2323

2424
echo md5(base64_encode($img));
2525
?>
2626
--EXPECT--
27-
5a8fe9864cbd20e5dbe730c77f30db95
27+
da884f488a851e0267a316ad232aee86

ext/gd/tests/imagerectangle_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ $image = imagecreatetruecolor( 100, 100 );
1616
imagerectangle( $image, 0, 0, 50, 50, imagecolorallocate($image, 255, 255, 255) );
1717

1818
ob_start();
19-
imagepng( $image, null, 9 );
19+
imagegd( $image );
2020
$img = ob_get_contents();
2121
ob_end_clean();
2222

2323
echo md5(base64_encode($img));
2424

2525
?>
2626
--EXPECT--
27-
282aaecfdd50091821d63093d9bb1bb9
27+
e7f8ca8c63fb08b248f3ed6435983aed

ext/gd/tests/imagesetbrush_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ imageline($mainimg, 50, 50, 50, 60, IMG_COLOR_BRUSHED);
2828

2929
// Get output and generate md5 hash
3030
ob_start();
31-
imagepng($mainimg, null, 9);
31+
imagegd($mainimg);
3232
$result_image = ob_get_contents();
3333
ob_end_clean();
3434
echo md5(base64_encode($result_image));
3535
?>
3636
--EXPECT--
37-
8168577c0d1fe6d9d11397cb15263d82
37+
2bb294c388d826cc9bba6c6fd31f265a

ext/gd/tests/imagesetthickness_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ imagesetthickness($image, 5);
2424
imagerectangle($image, 14, 14, 185, 85, $black);
2525

2626
ob_start();
27-
imagepng($image, null, 9);
27+
imagegd($image);
2828
$img = ob_get_contents();
2929
ob_end_clean();
3030

3131
echo md5(base64_encode($img));
3232
?>
3333
--EXPECT--
34-
93c3077f1bdc372cd0b0db96db282985
34+
1a6bc882772310d2e9b32cca2574236c

ext/gd/tests/imagestring_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ $white = imagecolorallocate($image, 255,255,255);
1515
$result = imagestring($image, 1, 5, 5, 'String Text', $white);
1616

1717
ob_start();
18-
imagepng($image, null, 9);
18+
imagegd($image);
1919
$img = ob_get_contents();
2020
ob_end_clean();
2121

2222
echo md5(base64_encode($img));
2323
?>
2424
--EXPECT--
25-
d0d2fe757400cb7846b36a8c34b41e4a
25+
7f146e3cdcaf89c6b9d68ccbb44cf94e

ext/gd/tests/imagestringup_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ $white = imagecolorallocate($image, 255,255,255);
1515
$result = imagestringup($image, 1, 5, 25, 'Str', $white);
1616

1717
ob_start();
18-
imagepng($image, null, 9);
18+
imagegd($image);
1919
$img = ob_get_contents();
2020
ob_end_clean();
2121

2222
echo md5(base64_encode($img));
2323
?>
2424
--EXPECT--
25-
7c28016adcf620b772af2a8655b87bd2
25+
7c55836800702bdd43b4c25d8ebcfcd0

0 commit comments

Comments
 (0)