com php-src: Fix and reactivate regression test for bug #50194: ext/gd/tests/bug50194.phpt
| From: | Christoph Michael Becker | Date: | Wed, 14 Sep 2016 22:46:00 +0000 |
| Subject: | com php-src: Fix and reactivate regression test for bug #50194: ext/gd/tests/bug50194.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94530@lists.php.net to get a copy of this message | ||
Commit: 7bfb7b62b1fa2a8a21c3718111424c80b91f6505
Author: Christoph M. Becker <cmb@php.net> Thu, 15 Sep 2016 00:34:55 +0200
Committer: Christoph M. Becker <cmbecker69@gmx.de> Thu, 15 Sep 2016 00:46:00 +0200
Parents: 36df4f8419f1109afbc920225ae72507c21da675
Branches: PHP-5.6 PHP-7.0 PHP-7.1
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7bfb7b62b1fa2a8a21c3718111424c80b91f6505
Log:
Fix and reactivate regression test for bug #50194
Apparently, different FreeType versions render the string differently, so
we have to cater to these slight differences. Unfortunately, the testing
framework doesn't yet offer a clean API for this, so we work around the
limitations by parsing and checking the output of test_image_equals_file().
Bugs:
https://bugs.php.net/50194
Changed paths:
M ext/gd/tests/bug50194.phpt
Diff:
diff --git a/ext/gd/tests/bug50194.phpt b/ext/gd/tests/bug50194.phpt
index 4b41a3a..f68165b 100644
--- a/ext/gd/tests/bug50194.phpt
+++ b/ext/gd/tests/bug50194.phpt
@@ -4,7 +4,7 @@ Bug #50194 (imagettftext broken on transparent background w/o alphablending)
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!function_exists('imagettftext')) die('skip imagettftext() not available');
-die('skip freetype issues');
+//die('skip freetype issues');
?>
--FILE--
<?php
@@ -20,11 +20,19 @@ $font = __DIR__ . DIRECTORY_SEPARATOR .. 'Tuffy.ttf';
imagettftext($im, 40, 0, 10, 40, $black, $font, $text);
imagesavealpha($im, true);
+ob_start();
test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'bug50194.png', $im);
+$output = ob_get_clean();
+assert(preg_match('/The images are equal|The images differ in (\d+) pixels/', $output,
$matches));
+if (isset($matches[1]) && $matches[1] > 2000) {
+ echo "The images differ in {$matches[1]} pixels.\n";
+} else {
+ echo "The images are similar.\n";
+}
imagedestroy($im);
?>
===DONE===
--EXPECT--
-The images are equal.
+The images are similar.
===DONE===