com php-src: Make test case more resilient: ext/gd/tests/bug67447.phpt
| From: | Christoph Michael Becker | Date: | Sun, 11 Sep 2016 16:29:27 +0000 |
| Subject: | com php-src: Make test case more resilient: ext/gd/tests/bug67447.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94425@lists.php.net to get a copy of this message | ||
Commit: 38455293f740e0444d16a247dc06db8d8ca18581
Author: Christoph M. Becker <cmbecker69@gmx.de> Sun, 11 Sep 2016 18:29:27 +0200
Parents: dc09f309335cf8df7d39adc03580ac8d4f0c78f5
Branches: PHP-5.6 PHP-7..0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=38455293f740e0444d16a247dc06db8d8ca18581
Log:
Make test case more resilient
This test case fails with external libgd, because libgd < 2.2.4 converts
palette images to truecolor (<https://github.com/libgd/libgd/issues/297>).
However, even if there happens no truecolor conversion, it is not guaranteed
that the palette indexes of the original and the cropped image are identical
(this is, for instance, not the case with current libgd master where the bug
has been fixed). Therefore we check for the expected RGBA value instead of
the palette index.
Changed paths:
M ext/gd/tests/bug67447.phpt
Diff:
diff --git a/ext/gd/tests/bug67447.phpt b/ext/gd/tests/bug67447.phpt
index 878b322..c174544 100644
--- a/ext/gd/tests/bug67447.phpt
+++ b/ext/gd/tests/bug67447.phpt
@@ -23,10 +23,19 @@ imagecolorallocate($image, 0, 0, 255); // first palette color = background
$red = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $red);
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' =>
250, 'height' => 250]);
-var_dump(imagecolorat($cropped, 249, 249) === $red);
+var_dump(imagecolorsforindex($cropped, imagecolorat($cropped, 249, 249)));
imagedestroy($image);
imagedestroy($cropped);
?>
--EXPECT--
bool(true)
-bool(true)
+array(4) {
+ ["red"]=>
+ int(255)
+ ["green"]=>
+ int(0)
+ ["blue"]=>
+ int(0)
+ ["alpha"]=>
+ int(0)
+}