diff options
Diffstat (limited to 'ext/gd/tests')
82 files changed, 379 insertions, 1266 deletions
diff --git a/ext/gd/tests/bug38212-mb.phpt b/ext/gd/tests/bug38212-mb.phpt index a7a3d65f13..d69d604e5d 100644 --- a/ext/gd/tests/bug38212-mb.phpt +++ b/ext/gd/tests/bug38212-mb.phpt @@ -6,12 +6,20 @@ Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters) ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $file = __DIR__ . '/bug38212私はガラスを食べられます.gd2'; $im1 = imagecreatetruecolor(10,100); imagefill($im1, 0,0, 0xffffff); imagegd2($im1, $file); -$im = imagecreatefromgd2part($file, 0,0, -25,10); + +trycatch_dump( + fn() => imagecreatefromgd2part($file, 0,0, -25, 10), + fn() => imagecreatefromgd2part($file, 0,0, 10, -25) +); + unlink($file); ?> ---EXPECTF-- -Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d +--EXPECT-- +!! [ValueError] Width must be at least 1 +!! [ValueError] Height must be at least 1 diff --git a/ext/gd/tests/bug38212.phpt b/ext/gd/tests/bug38212.phpt index 039c6f971b..8645989e09 100644 --- a/ext/gd/tests/bug38212.phpt +++ b/ext/gd/tests/bug38212.phpt @@ -6,12 +6,20 @@ Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters) ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $file = __DIR__ . '/bug38212.gd2'; $im1 = imagecreatetruecolor(10,100); imagefill($im1, 0,0, 0xffffff); imagegd2($im1, $file); -$im = imagecreatefromgd2part($file, 0,0, -25,10); + +trycatch_dump( + fn() => imagecreatefromgd2part($file, 0,0, -25, 10), + fn() => imagecreatefromgd2part($file, 0,0, 10, -25) +); + unlink($file); ?> ---EXPECTF-- -Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d +--EXPECT-- +!! [ValueError] Width must be at least 1 +!! [ValueError] Height must be at least 1 diff --git a/ext/gd/tests/bug39286-mb.phpt b/ext/gd/tests/bug39286-mb.phpt deleted file mode 100644 index 87390cb489..0000000000 --- a/ext/gd/tests/bug39286-mb.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Bug #39508 (imagefill crashes with small images 3 pixels or less) ---SKIPIF-- -<?php - if (!extension_loaded('gd')) die("skip gd extension not available\n"); -?> ---FILE-- -<?php -$img =imagecreatefromgd2part("foo私はガラスを食べられます.png",0, 100, 0, 100); -?> ---EXPECTF-- -Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d diff --git a/ext/gd/tests/bug39286.phpt b/ext/gd/tests/bug39286.phpt deleted file mode 100644 index 4fe4769a7b..0000000000 --- a/ext/gd/tests/bug39286.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Bug #39508 (imagefill crashes with small images 3 pixels or less) ---SKIPIF-- -<?php - if (!extension_loaded('gd')) die("skip gd extension not available\n"); -?> ---FILE-- -<?php -$img =imagecreatefromgd2part("foo.png",0, 100, 0, 100); -?> ---EXPECTF-- -Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d diff --git a/ext/gd/tests/bug41442.phpt b/ext/gd/tests/bug41442.phpt index 5c590deb77..351734931a 100644 --- a/ext/gd/tests/bug41442.phpt +++ b/ext/gd/tests/bug41442.phpt @@ -31,7 +31,9 @@ var_dump(imagecreatefromstring($str2)); echo "Done\n"; ?> ---EXPECTF-- -resource(%d) of type (gd) -resource(%d) of type (gd) +--EXPECT-- +object(GdImage)#2 (0) { +} +object(GdImage)#2 (0) { +} Done diff --git a/ext/gd/tests/bug66356.phpt b/ext/gd/tests/bug66356.phpt index 7dbfb1b40e..0e13bca9b3 100644 --- a/ext/gd/tests/bug66356.phpt +++ b/ext/gd/tests/bug66356.phpt @@ -28,8 +28,10 @@ var_dump(imagecrop($img, array("x" => 0x7fffff00, "y" => 0, "width" => 10, "heig var_dump(imagecrop($img, array("x" => 0, "y" => 0, "width" => 65535, "height" => 65535))); ?> --EXPECTF-- -resource(%d) of type (gd) -resource(%d) of type (gd) +object(GdImage)#2 (0) { +} +object(GdImage)#2 (0) { +} Array ( [x] => a @@ -39,11 +41,13 @@ Array ) Warning: imagecrop(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully - in %sbug66356.php on line %d + in %s on line %d bool(false) -resource(%d) of type (gd) -resource(%d) of type (gd) +object(GdImage)#2 (0) { +} +object(GdImage)#2 (0) { +} Warning: imagecrop(): product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully - in %sbug66356.php on line %d + in %s on line %d bool(false) diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt index 5cae5f8c98..c9a9588343 100644 --- a/ext/gd/tests/bug67248.phpt +++ b/ext/gd/tests/bug67248.phpt @@ -7,21 +7,19 @@ Bug #67248 (imageaffinematrixget missing check of parameters) ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + for($i=0;$i<7;$i++) { - imageaffinematrixget($i); + trycatch_dump( + fn() => imageaffinematrixget($i) + ); } ?> ---EXPECTF-- -Warning: imageaffinematrixget(): Array expected as options in %s on line %d - -Warning: imageaffinematrixget(): Array expected as options in %s on line %d - -Warning: imageaffinematrixget(): Number is expected as option in %s on line %d - -Warning: imageaffinematrixget(): Number is expected as option in %s on line %d - -Warning: imageaffinematrixget(): Number is expected as option in %s on line %d - -Warning: imageaffinematrixget(): Invalid type for element 5 in %s on line %d - -Warning: imageaffinematrixget(): Invalid type for element 6 in %s on line %d +--EXPECT-- +!! [TypeError] Array expected as options when using translate or scale +!! [TypeError] Array expected as options when using translate or scale +!! [TypeError] Number is expected as option when using rotate or shear +!! [TypeError] Number is expected as option when using rotate or shear +!! [TypeError] Number is expected as option when using rotate or shear +!! [ValueError] Invalid type for element 5 +!! [ValueError] Invalid type for element 6 diff --git a/ext/gd/tests/bug70976.phpt b/ext/gd/tests/bug70976.phpt index b4f5c9b78b..cd10a8ffc0 100644 --- a/ext/gd/tests/bug70976.phpt +++ b/ext/gd/tests/bug70976.phpt @@ -10,4 +10,5 @@ $img = imagerotate(imagecreate(10,10),45,0x7ffffff9); var_dump($img); ?> --EXPECT-- -resource(5) of type (gd) +object(GdImage)#2 (0) { +} diff --git a/ext/gd/tests/bug72494.phpt b/ext/gd/tests/bug72494.phpt index 4cca9aec8e..b01a19179a 100644 --- a/ext/gd/tests/bug72494.phpt +++ b/ext/gd/tests/bug72494.phpt @@ -6,10 +6,14 @@ if (!extension_loaded('gd')) die('skip gd extension not available'); ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $im = imagecreate(10,10); -imagecropauto($im, IMG_CROP_THRESHOLD, 0, 1337); + +trycatch_dump( + fn() => imagecropauto($im, IMG_CROP_THRESHOLD, 0, 1337) +); + ?> -===DONE=== ---EXPECTF-- -Warning: imagecropauto(): Color argument missing with threshold mode in %s on line %d -===DONE=== +--EXPECT-- +!! [ValueError] Color argument missing with threshold mode diff --git a/ext/gd/tests/bug72697.phpt b/ext/gd/tests/bug72697.phpt index 97bd3bdf88..2c293d14be 100644 --- a/ext/gd/tests/bug72697.phpt +++ b/ext/gd/tests/bug72697.phpt @@ -8,10 +8,16 @@ if (PHP_INT_MAX !== 9223372036854775807) die("skip for 64-bit long systems only" --FILE-- <?php +require __DIR__ . '/func.inc'; + $img=imagecreatetruecolor(10, 10); -imagetruecolortopalette($img, false, PHP_INT_MAX / 8); + +trycatch_dump( + fn() => imagetruecolortopalette($img, false, PHP_INT_MAX / 8) +); + ?> DONE ---EXPECTF-- -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than 2147483647 in %sbug72697.php on line %d +--EXPECT-- +!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 DONE diff --git a/ext/gd/tests/bug72709.phpt b/ext/gd/tests/bug72709.phpt index 1c5b1f4ae0..2963f1c104 100644 --- a/ext/gd/tests/bug72709.phpt +++ b/ext/gd/tests/bug72709.phpt @@ -7,12 +7,18 @@ if (!extension_loaded('gd')) die('skip ext/gd not available'); --FILE-- <?php $im = imagecreatetruecolor(1, 1); -var_dump(imagesetstyle($im, array())); + +try { + var_dump(imagesetstyle($im, array())); +} +catch (\Error $ex) { + echo $ex->getMessage() . "\n"; +} + imagesetpixel($im, 0, 0, IMG_COLOR_STYLED); imagedestroy($im); ?> ====DONE==== ---EXPECTF-- -Warning: imagesetstyle(): styles array must not be empty in %s%ebug72709.php on line %d -bool(false) +--EXPECT-- +Styles array must not be empty ====DONE==== diff --git a/ext/gd/tests/bug72730.phpt b/ext/gd/tests/bug72730.phpt index 403354d1e2..09b6657add 100644 --- a/ext/gd/tests/bug72730.phpt +++ b/ext/gd/tests/bug72730.phpt @@ -6,10 +6,15 @@ if (!function_exists("imagecreatetruecolor")) die("skip"); ?> --FILE-- <?php + +require __DIR__ . '/func.inc'; + $img = imagecreatetruecolor(1, 1); -imagegammacorrect($img, -1, 1337); + +trycatch_dump( + fn() => imagegammacorrect($img, -1, 1337) +); + ?> -DONE ---EXPECTF-- -Warning: imagegammacorrect(): Gamma values should be positive in %sbug72730.php on line %d -DONE +--EXPECT-- +!! [ValueError] Gamma values must be positive diff --git a/ext/gd/tests/bug73968.phpt b/ext/gd/tests/bug73968.phpt index 2211840f58..c1101c61bf 100644 --- a/ext/gd/tests/bug73968.phpt +++ b/ext/gd/tests/bug73968.phpt @@ -9,7 +9,6 @@ if (!extension_loaded('gd')) die('skip gd extension not available'); $im = imagecreatefromxbm(__DIR__ . DIRECTORY_SEPARATOR . 'bug73968.xbm'); var_dump($im); ?> -===DONE=== ---EXPECTF-- -resource(%d) of type (gd) -===DONE=== +--EXPECT-- +object(GdImage)#1 (0) { +} diff --git a/ext/gd/tests/bug74435.phpt b/ext/gd/tests/bug74435.phpt index 9d11eb3839..78f2103247 100644 --- a/ext/gd/tests/bug74435.phpt +++ b/ext/gd/tests/bug74435.phpt @@ -21,7 +21,6 @@ for ($i = 0; $i < $width; $i += 16) { } } ?> -===DONE=== ---EXPECTF-- -resource(%d) of type (gd) -===DONE=== +--EXPECT-- +object(GdImage)#1 (0) { +} diff --git a/ext/gd/tests/bug77269.phpt b/ext/gd/tests/bug77269.phpt index c89f674b8a..527f26c397 100644 --- a/ext/gd/tests/bug77269.phpt +++ b/ext/gd/tests/bug77269.phpt @@ -10,9 +10,8 @@ memory_limit=2G --FILE-- <?php $im = imagecreate(2**28, 1); -if(is_resource($im)) { - imagescale($im, 1, 1, IMG_TRIANGLE); -} +imagescale($im, 1, 1, IMG_TRIANGLE); + ?> ===DONE=== --EXPECTF-- diff --git a/ext/gd/tests/bug77391.phpt b/ext/gd/tests/bug77391.phpt index aa76c1470e..fbfa8a8026 100644 --- a/ext/gd/tests/bug77391.phpt +++ b/ext/gd/tests/bug77391.phpt @@ -9,7 +9,6 @@ if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstrea <?php var_dump(imagecreatefrombmp(__DIR__ . '/bug77391.bmp')); ?> -===DONE=== ---EXPECTF-- -resource(%d) of type (gd) -===DONE=== +--EXPECT-- +object(GdImage)#1 (0) { +} diff --git a/ext/gd/tests/func.inc b/ext/gd/tests/func.inc index 34d9c47155..faa0b06816 100644 --- a/ext/gd/tests/func.inc +++ b/ext/gd/tests/func.inc @@ -146,3 +146,21 @@ function save_actual_image($image) $filename = "{$pathinfo['dirname']}/{$pathinfo['filename']}.out.png"; imagepng($image, $filename); } + +/** + * Replicates write errors to the output log, but by catching + * and formatting exceptions instead so they have a consistent + * output + */ + +function trycatch_dump(...$tests) { + foreach ($tests as $test) { + try { + var_dump($test()); + } + catch (\Error $e) { + echo '!! [' . get_class($e) . '] ' . $e->getMessage() . "\n"; + } + } +} + diff --git a/ext/gd/tests/gdimage_prevent_cloning.phpt b/ext/gd/tests/gdimage_prevent_cloning.phpt new file mode 100644 index 0000000000..0f5c198e88 --- /dev/null +++ b/ext/gd/tests/gdimage_prevent_cloning.phpt @@ -0,0 +1,20 @@ +--TEST-- +Checks that GdImage instances cannot be cloned +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +?> +--FILE-- +<?php + + $img_src = imagecreatetruecolor(32, 32); + $img_dst = clone $img_src; + +?> +--EXPECTF-- +Fatal error: Uncaught Error: Trying to clone an uncloneable object of class GdImage in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d diff --git a/ext/gd/tests/gdimage_prevent_serialization.phpt b/ext/gd/tests/gdimage_prevent_serialization.phpt new file mode 100644 index 0000000000..ef08444d37 --- /dev/null +++ b/ext/gd/tests/gdimage_prevent_serialization.phpt @@ -0,0 +1,21 @@ +--TEST-- +GdImage instances must not be serialized +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +?> +--FILE-- +<?php + + $img_src = imagecreatetruecolor(32, 32); + var_dump(serialize($img_src)); + +?> +--EXPECTF-- +Fatal error: Uncaught Exception: Serialization of 'GdImage' is not allowed in %s:%d +Stack trace: +#0 %s(%d): serialize(Object(GdImage)) +#1 {main} + thrown in %s on line %d diff --git a/ext/gd/tests/image2wbmp_error.phpt b/ext/gd/tests/image2wbmp_error.phpt deleted file mode 100644 index 8d8d836ef7..0000000000 --- a/ext/gd/tests/image2wbmp_error.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -image2wbmp() is deprecated ---SKIPIF-- -<?php -if (!extension_loaded('gd')) die('skip gd extension not available'); -?> ---FILE-- -<?php -$im = imagecreate(10, 10); -imagecolorallocate($im, 0, 0, 0); -image2wbmp($im, __DIR__ . '/image2wbmp_error.wbmp'); -?> -===DONE=== ---CLEAN-- -<?php -unlink(__DIR__ . '/image2wbmp_error.wbmp'); -?> ---EXPECTF-- -Deprecated: Function image2wbmp() is deprecated in %s on line %d -===DONE=== diff --git a/ext/gd/tests/imageantialias_error1.phpt b/ext/gd/tests/imageantialias_error1.phpt deleted file mode 100644 index 8a9d5315a6..0000000000 --- a/ext/gd/tests/imageantialias_error1.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource in imageantialias() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imageantialias($image, true)); -?> ---EXPECTF-- -Warning: imageantialias(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagebmp_nullbyte_injection.phpt b/ext/gd/tests/imagebmp_nullbyte_injection.phpt index 0b6d1843d3..00d0a7168c 100644 --- a/ext/gd/tests/imagebmp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagebmp_nullbyte_injection.phpt @@ -8,10 +8,11 @@ if (!gd_info()['BMP Support']) die('skip BMP support not available'); --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagebmp($image, "./foo\0bar")); +try { + imagebmp($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> -===DONE=== ---EXPECTF-- -Warning: imagebmp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d -bool(false) -===DONE=== +--EXPECT-- +Invalid 2nd parameter, filename must not contain null bytes diff --git a/ext/gd/tests/imagechar_error2.phpt b/ext/gd/tests/imagechar_error2.phpt deleted file mode 100644 index 1666788ead..0000000000 --- a/ext/gd/tests/imagechar_error2.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Testing error on non-image resource parameter 1 of imagechar() of GD library ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php - -$result = imagechar(tmpfile(), 1, 5, 5, 'C', 1); - -?> ---EXPECTF-- -Warning: imagechar(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagecharup_error2.phpt b/ext/gd/tests/imagecharup_error2.phpt deleted file mode 100644 index e2db7bb558..0000000000 --- a/ext/gd/tests/imagecharup_error2.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Testing error on non-image resource parameter 1 of imagecharup() of GD library ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php - -$result = imagecharup(tmpfile(), 1, 5, 5, 'C', 1); - -?> ---EXPECTF-- -Warning: imagecharup(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagecolorallocate_variation5.phpt b/ext/gd/tests/imagecolorallocate_variation5.phpt index ac3e4bb20e..ae6acb18f6 100644 --- a/ext/gd/tests/imagecolorallocate_variation5.phpt +++ b/ext/gd/tests/imagecolorallocate_variation5.phpt @@ -11,6 +11,8 @@ if(!function_exists('imagecreatetruecolor')) { ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + /* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) * Description: Allocate a color for an image * Source code: ext/gd/gd.c @@ -38,14 +40,17 @@ $values = array( // loop through each element of the array for blue foreach($values as $key => $value) { - echo "\n--$key--\n"; - var_dump( imagecolorallocate($im, $value, $green, $blue) ); - var_dump( imagecolorallocate($im, $red, $value, $blue) ); - var_dump( imagecolorallocate($im, $red, $green, $value) ); + echo "\n--$key--\n"; + + trycatch_dump( + fn() => imagecolorallocate($im, $value, $green, $blue), + fn() => imagecolorallocate($im, $red, $value, $blue), + fn() => imagecolorallocate($im, $red, $green, $value) + ); }; ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing imagecolorallocate() : usage variations *** --Octal 000-- @@ -59,15 +64,9 @@ int(657930) int(657930) --Octal -012-- - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) --Octal 0377-- int(16714250) @@ -85,15 +84,9 @@ int(657930) int(657930) --Hexa-decimal -0xA-- - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) --Hexa-decimal 0xFF-- int(16714250) diff --git a/ext/gd/tests/imagecolorallocate_variation6.phpt b/ext/gd/tests/imagecolorallocate_variation6.phpt index a3649be71f..9f21739ff1 100644 --- a/ext/gd/tests/imagecolorallocate_variation6.phpt +++ b/ext/gd/tests/imagecolorallocate_variation6.phpt @@ -11,6 +11,8 @@ if(!function_exists('imagecreatetruecolor')) { ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + /* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) * Description: Allocate a color for an image * Source code: ext/gd/gd.c @@ -34,75 +36,42 @@ foreach($values as $key => $value) { //Need to be created every time to get expected return value $im_palette = imagecreate(200, 200); $im_true_color = imagecreatetruecolor(200, 200); - var_dump( imagecolorallocate($im_palette, $value, 0, 0) ); - var_dump( imagecolorallocate($im_true_color, $value, 0, 0) ); - var_dump( imagecolorallocate($im_palette, 0, $value, 0) ); - var_dump( imagecolorallocate($im_true_color, 0, $value, 0) ); - var_dump( imagecolorallocate($im_palette, 0, 0, $value) ); - var_dump( imagecolorallocate($im_true_color, 0, 0, $value) ); + + trycatch_dump( + fn() => imagecolorallocate($im_palette, $value, 0, 0), + fn() => imagecolorallocate($im_true_color, $value, 0, 0), + fn() => imagecolorallocate($im_palette, 0, $value, 0), + fn() => imagecolorallocate($im_true_color, 0, $value, 0), + fn() => imagecolorallocate($im_palette, 0, 0, $value), + fn() => imagecolorallocate($im_true_color, 0, 0, $value) + ); }; ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing imagecolorallocate() : usage variations *** --Decimal 256-- - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) --Octal 0400-- - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) --Hexa-decimal 0x100-- - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Red component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Green component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) - -Warning: imagecolorallocate(): Blue component is out of range in %s on line %d -bool(false) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) ===DONE=== diff --git a/ext/gd/tests/imagecolorallocatealpha_error1.phpt b/ext/gd/tests/imagecolorallocatealpha_error1.phpt deleted file mode 100644 index 793c02d106..0000000000 --- a/ext/gd/tests/imagecolorallocatealpha_error1.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Testing imagecolorallocatealpha(): Wrong types for parameter 1 ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$resource = tmpfile(); - -imagecolorallocatealpha($resource, 255, 255, 255, 50); -imagecolorallocatealpha('string', 255, 255, 255, 50); -imagecolorallocatealpha(array(), 255, 255, 255, 50); -imagecolorallocatealpha(null, 255, 255, 255, 50); -?> ---EXPECTF-- -Warning: imagecolorallocatealpha(): supplied resource is not a valid Image resource in %s on line %d - -Warning: imagecolorallocatealpha() expects parameter 1 to be resource, %s given in %s on line %d - -Warning: imagecolorallocatealpha() expects parameter 1 to be resource, array given in %s on line %d - -Warning: imagecolorallocatealpha() expects parameter 1 to be resource, null given in %s on line %d diff --git a/ext/gd/tests/imagecolordeallocate_error1.phpt b/ext/gd/tests/imagecolordeallocate_error1.phpt deleted file mode 100644 index 82460139b6..0000000000 --- a/ext/gd/tests/imagecolordeallocate_error1.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Testing imagecolordeallocate() of GD library with invalid resource type ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php - -$image = imagecreatetruecolor(180, 30); -$white = imagecolorallocate($image, 255, 255, 255); - -$resource = tmpfile(); - -$result = imagecolordeallocate($resource, $white); - -?> ---EXPECTF-- -Warning: imagecolordeallocate(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagecolordeallocate_error3.phpt b/ext/gd/tests/imagecolordeallocate_error3.phpt index e9be1ea66a..f81b52192a 100644 --- a/ext/gd/tests/imagecolordeallocate_error3.phpt +++ b/ext/gd/tests/imagecolordeallocate_error3.phpt @@ -9,14 +9,17 @@ Rafael Dohms <rdohms [at] gmail [dot] com> ?> --FILE-- <?php +require_once __DIR__ . '/func.inc'; + $image = imagecreate(180, 30); $white = imagecolorallocate($image, 255, 255, 255); $totalColors = imagecolorstotal($image); -$result = imagecolordeallocate($image, $totalColors + 100); -var_dump($result); +trycatch_dump( + fn() => imagecolordeallocate($image, $totalColors + 100) +); + ?> ---EXPECTF-- -Warning: imagecolordeallocate(): Color index 101 out of range in %s on line %d -bool(false) +--EXPECT-- +!! [ValueError] Color index 101 out of range diff --git a/ext/gd/tests/imagecolordeallocate_error4.phpt b/ext/gd/tests/imagecolordeallocate_error4.phpt index 22fc2fa3ef..4d3009dcae 100644 --- a/ext/gd/tests/imagecolordeallocate_error4.phpt +++ b/ext/gd/tests/imagecolordeallocate_error4.phpt @@ -9,14 +9,17 @@ Rafael Dohms <rdohms [at] gmail [dot] com> ?> --FILE-- <?php + +require_once __DIR__ . '/func.inc'; $image = imagecreate(180, 30); $white = imagecolorallocate($image, 255, 255, 255); $totalColors = imagecolorstotal($image); -$result = imagecolordeallocate($image, -1.0); -var_dump($result); +trycatch_dump( + fn() => imagecolordeallocate($image, -1.0) +); + ?> ---EXPECTF-- -Warning: imagecolordeallocate(): Color index -1 out of range in %s on line %d -bool(false) +--EXPECT-- +!! [ValueError] Color index -1 out of range diff --git a/ext/gd/tests/imagecolorstotal_error.phpt b/ext/gd/tests/imagecolorstotal_error.phpt deleted file mode 100644 index 59999423ca..0000000000 --- a/ext/gd/tests/imagecolorstotal_error.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -Test imagecolorstotal() function : error conditions - Pass incorrect number of arguments ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('imagecolorstotal')) { - die('skip imagecolorstotal function is not available'); -} -?> ---FILE-- -<?php -/* Prototype : int imagecolorstotal ( resource $image ) - * Description: Find out the number of colors in an image's palette - * Source code: ext/gd/gd.c - */ - -echo "*** Testing imagecolorstotal() : error conditions ***\n"; - -// Get a resource -$im = fopen(__FILE__, 'r'); - -echo "\n-- Testing imagecolorstotal() function with Zero arguments --\n"; -var_dump( imagecolorstotal() ); - -echo "\n-- Testing imagecolorstotal() function with more than expected no. of arguments --\n"; -$extra_arg = false; -var_dump( imagecolorstotal($im, $extra_arg) ); - -echo "\n-- Testing imagecolorstotal() function with a invalid resource\n"; -var_dump( imagecolorstotal($im) ); - -fclose($im); -?> -===DONE=== ---EXPECTF-- -*** Testing imagecolorstotal() : error conditions *** - --- Testing imagecolorstotal() function with Zero arguments -- - -Warning: imagecolorstotal() expects exactly 1 parameter, 0 given in %s on line %d -NULL - --- Testing imagecolorstotal() function with more than expected no. of arguments -- - -Warning: imagecolorstotal() expects exactly 1 parameter, 2 given in %s on line %d -NULL - --- Testing imagecolorstotal() function with a invalid resource - -Warning: imagecolorstotal(): supplied resource is not a valid Image resource in %s on line %d -bool(false) -===DONE=== diff --git a/ext/gd/tests/imageconvolution_error2.phpt b/ext/gd/tests/imageconvolution_error2.phpt index 217e3e1547..d26851c26c 100644 --- a/ext/gd/tests/imageconvolution_error2.phpt +++ b/ext/gd/tests/imageconvolution_error2.phpt @@ -9,6 +9,8 @@ if (!extension_loaded("gd")) die("skip GD not present"); ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $image = imagecreatetruecolor(180, 30); // Writes the text and apply a gaussian blur on the image @@ -19,8 +21,10 @@ $gaussian = array( array(2.0, 4.0, 2.0) ); -var_dump(imageconvolution($image, $gaussian, 16, 0)); +trycatch_dump( + fn() => imageconvolution($image, $gaussian, 16, 0) +); + ?> ---EXPECTF-- -Warning: imageconvolution(): You must have 3x3 array in %s on line %d -bool(false) +--EXPECT-- +!! [ValueError] Convolution matrix must be a 3x3 array diff --git a/ext/gd/tests/imageconvolution_error3.phpt b/ext/gd/tests/imageconvolution_error3.phpt index 5f1ddc95be..8974fdbda0 100644 --- a/ext/gd/tests/imageconvolution_error3.phpt +++ b/ext/gd/tests/imageconvolution_error3.phpt @@ -9,6 +9,8 @@ if (!extension_loaded("gd")) die("skip GD not present"); ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $image = imagecreatetruecolor(180, 30); // Writes the text and apply a gaussian blur on the image @@ -20,8 +22,18 @@ $gaussian = array( array(1.0, 2.0) ); -var_dump(imageconvolution($image, $gaussian, 16, 0)); +$gaussian_bad_key = array( + array(1.0, 2.0, 1.0), + array(2.0, 4.0, 2.0), + array(1.0, 2.0, 'x' => 1.0) +); + +trycatch_dump( + fn() => imageconvolution($image, $gaussian, 16, 0), + fn() => imageconvolution($image, $gaussian_bad_key, 16, 0) +); + ?> ---EXPECTF-- -Warning: imageconvolution(): You must have 3x3 array in %s on line %d -bool(false) +--EXPECT-- +!! [ValueError] Convolution matrix must be a 3x3 array, matrix[2] only has 2 elements +!! [ValueError] Convolution matrix must be a 3x3 array, matrix[2][2] cannot be found (missing integer key) diff --git a/ext/gd/tests/imagecreate_error.phpt b/ext/gd/tests/imagecreate_error.phpt new file mode 100644 index 0000000000..9fd8679c13 --- /dev/null +++ b/ext/gd/tests/imagecreate_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing imagecreate(): error on out of bound parameters +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreate")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php + +require __DIR__ . '/func.inc'; + +trycatch_dump( + fn() => imagecreate(-1, 30), + fn() => imagecreate(30, -1) +); + +?> +--EXPECT-- +!! [ValueError] Invalid width (x_size) +!! [ValueError] Invalid height (y_size) diff --git a/ext/gd/tests/imagecreatetruecolor_error2.phpt b/ext/gd/tests/imagecreatetruecolor_error2.phpt index 3ab4cf1e1f..e2784b1530 100644 --- a/ext/gd/tests/imagecreatetruecolor_error2.phpt +++ b/ext/gd/tests/imagecreatetruecolor_error2.phpt @@ -9,16 +9,15 @@ Rafael Dohms <rdohms [at] gmail [dot] com> ?> --FILE-- <?php -$image = imagecreatetruecolor(-1, 30); -$image = imagecreatetruecolor(30, -1); -$image = imagecreatetruecolor(999999999999999999999999999, 30); -$image = imagecreatetruecolor(30, 999999999999999999999999999); -?> ---EXPECTF-- -Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d -Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d +require __DIR__ . '/func.inc'; -Warning: imagecreatetruecolor() expects parameter 1 to be int, float given in %s on line %d +trycatch_dump( + fn() => imagecreatetruecolor(-1, 30), + fn() => imagecreatetruecolor(30, -1) +); -Warning: imagecreatetruecolor() expects parameter 2 to be int, float given in %s on line %d +?> +--EXPECT-- +!! [ValueError] Invalid width (x_size) +!! [ValueError] Invalid height (y_size) diff --git a/ext/gd/tests/imageellipse_error7.phpt b/ext/gd/tests/imageellipse_error7.phpt deleted file mode 100644 index 0b4c1f549d..0000000000 --- a/ext/gd/tests/imageellipse_error7.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Testing wrong param passing imageellipse() of GD library ---CREDITS-- -Ivan Rosolen <contato [at] ivanrosolen [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php - -// Create a resource -$image = tmpfile(); - -// try to draw a white ellipse -imageellipse($image, 200, 150, 300, 200, 16777215); -?> ---EXPECTF-- -Warning: imageellipse(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagefilledpolygon_negative.phpt b/ext/gd/tests/imagefilledpolygon_negative.phpt index a572a195f5..165fa1c13b 100644 --- a/ext/gd/tests/imagefilledpolygon_negative.phpt +++ b/ext/gd/tests/imagefilledpolygon_negative.phpt @@ -6,10 +6,16 @@ imagefilledpolygon() with a negative num of points ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $im = imagecreate(100, 100); $black = imagecolorallocate($im, 0, 0, 0); -if (imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false"; + +trycatch_dump( + fn() => imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black) +); + imagedestroy($im); ?> ---EXPECTF-- -Warning: imagefilledpolygon(): You must give a positive number of points in %s on line %d +--EXPECT-- +!! [ValueError] You must give a positive number of points diff --git a/ext/gd/tests/imagefilltoborder_error6.phpt b/ext/gd/tests/imagefilltoborder_error6.phpt deleted file mode 100644 index 421c5932ee..0000000000 --- a/ext/gd/tests/imagefilltoborder_error6.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Testing wrong param passing imagefilltoborder() of GD library ---CREDITS-- -Ivan Rosolen <contato [at] ivanrosolen [dot] com> -#testfest PHPSP on 2009-06-30 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -// Create a image -$image = imagecreatetruecolor( 100, 100 ); - -// Draw a rectangle -imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); - -// Draw an ellipse to fill with a black border -imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); - -// Try to fill border -$image_foo = tmpfile(); -imagefilltoborder( $image_foo, 50, 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); - -?> ---EXPECTF-- -Warning: imagefilltoborder(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagefilter_error1.phpt b/ext/gd/tests/imagefilter_error1.phpt index 41637994b4..407944d899 100644 --- a/ext/gd/tests/imagefilter_error1.phpt +++ b/ext/gd/tests/imagefilter_error1.phpt @@ -11,8 +11,11 @@ if (!extension_loaded("gd")) die("skip GD not present"); <?php $image = imagecreatetruecolor(180, 30); -var_dump(imagefilter($image)); +try { + var_dump(imagefilter($image)); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: Wrong parameter count for imagefilter() in %s on line %d -NULL +--EXPECT-- +Wrong parameter count for imagefilter() diff --git a/ext/gd/tests/imagefilter_error10.phpt b/ext/gd/tests/imagefilter_error10.phpt deleted file mode 100644 index 0cea9aa3c1..0000000000 --- a/ext/gd/tests/imagefilter_error10.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of EMBOSS in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_EMBOSS)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error11.phpt b/ext/gd/tests/imagefilter_error11.phpt deleted file mode 100644 index 2f162045b8..0000000000 --- a/ext/gd/tests/imagefilter_error11.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource passing of EDGEDETECT in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_EDGEDETECT)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error12.phpt b/ext/gd/tests/imagefilter_error12.phpt deleted file mode 100644 index 29664518a0..0000000000 --- a/ext/gd/tests/imagefilter_error12.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of COLORIZE in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_COLORIZE, 255, 255, 255)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error15.phpt b/ext/gd/tests/imagefilter_error15.phpt deleted file mode 100644 index 9c76bf24ab..0000000000 --- a/ext/gd/tests/imagefilter_error15.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of CONTRAST in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_CONTRAST, 2)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error17.phpt b/ext/gd/tests/imagefilter_error17.phpt deleted file mode 100644 index 9a3ba39439..0000000000 --- a/ext/gd/tests/imagefilter_error17.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of GRAYSCALE in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_GRAYSCALE)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error18.phpt b/ext/gd/tests/imagefilter_error18.phpt deleted file mode 100644 index d96d02426f..0000000000 --- a/ext/gd/tests/imagefilter_error18.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of NEGATE in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_NEGATE)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error20.phpt b/ext/gd/tests/imagefilter_error20.phpt deleted file mode 100644 index f1a330dbed..0000000000 --- a/ext/gd/tests/imagefilter_error20.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of BRIGHTNESS in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_BRIGHTNESS, 1)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error4.phpt b/ext/gd/tests/imagefilter_error4.phpt deleted file mode 100644 index f60ce11b42..0000000000 --- a/ext/gd/tests/imagefilter_error4.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of PIXELATE in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_PIXELATE, 3)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error6.phpt b/ext/gd/tests/imagefilter_error6.phpt deleted file mode 100644 index 1ace03cba3..0000000000 --- a/ext/gd/tests/imagefilter_error6.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of SMOOTH in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_SMOOTH, 3.0)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error7.phpt b/ext/gd/tests/imagefilter_error7.phpt deleted file mode 100644 index 4e095801e8..0000000000 --- a/ext/gd/tests/imagefilter_error7.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of MEAN_REMOVAL in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_MEAN_REMOVAL)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error8.phpt b/ext/gd/tests/imagefilter_error8.phpt deleted file mode 100644 index 5086e6421d..0000000000 --- a/ext/gd/tests/imagefilter_error8.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of SELECTIVE_BLUR in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_SELECTIVE_BLUR)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagefilter_error9.phpt b/ext/gd/tests/imagefilter_error9.phpt deleted file mode 100644 index 268a65f0f7..0000000000 --- a/ext/gd/tests/imagefilter_error9.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Testing wrong parameter resource of GAUSSIAN_BLUR in imagefilter() of GD library ---CREDITS-- -Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); - -var_dump(imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR)); -?> ---EXPECTF-- -Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imagegammacorrect_error2.phpt b/ext/gd/tests/imagegammacorrect_error2.phpt deleted file mode 100644 index fd6d136ae8..0000000000 --- a/ext/gd/tests/imagegammacorrect_error2.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Testing error with non-Image resource paramenter of imagegammacorrect() of GD library, ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = tmpfile(); -$gamma = imagegammacorrect($image, 1, 5); - -?> ---EXPECTF-- -Warning: imagegammacorrect(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagegd2_nullbyte_injection.phpt b/ext/gd/tests/imagegd2_nullbyte_injection.phpt index 2fc3050421..30394cc1a5 100644 --- a/ext/gd/tests/imagegd2_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegd2_nullbyte_injection.phpt @@ -7,8 +7,11 @@ Testing null byte injection in imagegd2 --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagegd2($image, "./foo\0bar")); +try { + imagegd($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: imagegd2() expects parameter 2 to be a valid path, string given in %s on line %d -NULL +--EXPECT-- +imagegd() expects parameter 2 to be a valid path, string given diff --git a/ext/gd/tests/imagegd_nullbyte_injection.phpt b/ext/gd/tests/imagegd_nullbyte_injection.phpt index f5479a0050..f53d9b5dac 100644 --- a/ext/gd/tests/imagegd_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegd_nullbyte_injection.phpt @@ -7,8 +7,11 @@ Testing null byte injection in imagegd --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagegd($image, "./foo\0bar")); +try { + imagegd($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: imagegd() expects parameter 2 to be a valid path, string given in %s on line %d -NULL +--EXPECT-- +imagegd() expects parameter 2 to be a valid path, string given diff --git a/ext/gd/tests/imagegif_nullbyte_injection.phpt b/ext/gd/tests/imagegif_nullbyte_injection.phpt index c5acdd489e..4518ecad27 100644 --- a/ext/gd/tests/imagegif_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegif_nullbyte_injection.phpt @@ -4,15 +4,14 @@ Testing null byte injection in imagegif <?php if(!extension_loaded('gd')){ die('skip gd extension not available'); } ?> ---CLEAN-- -$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); -foreach (glob($tempdir . "/test*") as $file ) { unlink($file); } -rmdir($tempdir); --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagegif($image, "./foo\0bar")); +try { + imagegif($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: imagegif(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d -bool(false) +--EXPECT-- +Invalid 2nd parameter, filename must not contain null bytes diff --git a/ext/gd/tests/imageinterlace_error2.phpt b/ext/gd/tests/imageinterlace_error2.phpt deleted file mode 100644 index e20f3ae901..0000000000 --- a/ext/gd/tests/imageinterlace_error2.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Testing resource that is not a image to imageinterlace() of GD library ---CREDITS-- -Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$image = fopen('php://stdin', 'r'); -var_dump(imageinterlace($image)); -?> ---EXPECTF-- -Warning: imageinterlace(): supplied resource is not a valid Image resource in %s on line %d -bool(false) diff --git a/ext/gd/tests/imageistruecolor_error1.phpt b/ext/gd/tests/imageistruecolor_error1.phpt deleted file mode 100644 index ab0a9fe653..0000000000 --- a/ext/gd/tests/imageistruecolor_error1.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Testing imageistruecolor(): wrong parameters ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); - if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); -?> ---FILE-- -<?php -$image = imagecreatetruecolor(180, 30); -$resource = tmpfile(); - -imageistruecolor('string'); -imageistruecolor($resource); -imageistruecolor(array()); -?> ---EXPECTF-- -Warning: imageistruecolor() expects parameter 1 to be resource, string given in %s on line %d - -Warning: imageistruecolor(): supplied resource is not a valid Image resource in %s on line %d - -Warning: imageistruecolor() expects parameter 1 to be resource, array given in %s on line %d diff --git a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt index 29cb537c3a..1a7f6da03c 100644 --- a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt +++ b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt @@ -8,15 +8,14 @@ if (!isset($support['JPEG Support']) || $support['JPEG Support'] === false) { print 'skip jpeg support not available'; } ?> ---CLEAN-- -$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); -foreach (glob($tempdir . "/test*") as $file ) { unlink($file); } -rmdir($tempdir); --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagejpeg($image, "./foo\0bar")); +try { + imagejpeg($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: imagejpeg(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d -bool(false) +--EXPECT-- +Invalid 2nd parameter, filename must not contain null bytes diff --git a/ext/gd/tests/imagelayereffect_error3.phpt b/ext/gd/tests/imagelayereffect_error3.phpt deleted file mode 100644 index 63d1e0e951..0000000000 --- a/ext/gd/tests/imagelayereffect_error3.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Testing imagelayereffect() with invalid resource of GD library ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); - if (!GD_BUNDLED) die('skip function only available in bundled, external GD detected'); -?> ---FILE-- -<?php -$resource = tmpfile(); -$layer = imagelayereffect($resource, IMG_EFFECT_REPLACE); -?> ---EXPECTF-- -Warning: imagelayereffect(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagepalettetotruecolor_basic.phpt b/ext/gd/tests/imagepalettetotruecolor_basic.phpt index 63a2b51e77..89fb514a5f 100644 --- a/ext/gd/tests/imagepalettetotruecolor_basic.phpt +++ b/ext/gd/tests/imagepalettetotruecolor_basic.phpt @@ -9,7 +9,7 @@ Carlos André Ferrari <caferrari [at] gmail [dot] com> --FILE-- <?php $im = imagecreate(100, 100); -var_dump(is_resource($im)); +var_dump($im instanceof GdImage); var_dump(imageistruecolor($im)); var_dump(imagepalettetotruecolor($im)); var_dump(imageistruecolor($im)); diff --git a/ext/gd/tests/imagepalettetotruecolor_error3.phpt b/ext/gd/tests/imagepalettetotruecolor_error3.phpt deleted file mode 100644 index 42a7e71773..0000000000 --- a/ext/gd/tests/imagepalettetotruecolor_error3.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -imagepalettetotruecollor must return an error if not an image resource is given ---CREDITS-- -Carlos André Ferrari <caferrari [at] gmail [dot] com> ---SKIPIF-- -<?php - if (!extension_loaded('gd')) die("skip gd extension not available."); -?> ---FILE-- -<?php -$im = fopen('php://memory', 'w'); -imagepalettetotruecolor($im); -?> ---EXPECTF-- -Warning: imagepalettetotruecolor(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagepng_nullbyte_injection.phpt b/ext/gd/tests/imagepng_nullbyte_injection.phpt index 271d4d5bd3..86d614ab60 100644 --- a/ext/gd/tests/imagepng_nullbyte_injection.phpt +++ b/ext/gd/tests/imagepng_nullbyte_injection.phpt @@ -8,15 +8,14 @@ if (!isset($support['PNG Support']) || $support['PNG Support'] === false) { print 'skip png support not available'; } ?> ---CLEAN-- -$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); -foreach (glob($tempdir . "/test*") as $file ) { unlink($file); } -rmdir($tempdir); --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagepng($image, "./foo\0bar")); +try { + imagepng($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECTF-- -Warning: imagepng(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d -bool(false) +Invalid 2nd parameter, filename must not contain null bytes diff --git a/ext/gd/tests/imagepolygon_negative.phpt b/ext/gd/tests/imagepolygon_negative.phpt index d122a3bbaa..96b2e7591e 100644 --- a/ext/gd/tests/imagepolygon_negative.phpt +++ b/ext/gd/tests/imagepolygon_negative.phpt @@ -6,10 +6,16 @@ imagepolygon() with a negative num of points ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $im = imagecreate(100, 100); $black = imagecolorallocate($im, 0, 0, 0); -if (imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false"; + +trycatch_dump( + fn() => imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black) +); + imagedestroy($im); ?> ---EXPECTF-- -Warning: imagepolygon(): You must give a positive number of points in %s on line %d +--EXPECT-- +!! [ValueError] You must give a positive number of points diff --git a/ext/gd/tests/imagerectangle_error2.phpt b/ext/gd/tests/imagerectangle_error2.phpt deleted file mode 100644 index 4e2e665bda..0000000000 --- a/ext/gd/tests/imagerectangle_error2.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -Testing wrong param passing imagerectangle() of GD library ---CREDITS-- -Ivan Rosolen <contato [at] ivanrosolen [dot] com> -#testfest PHPSP on 2009-06-30 ---SKIPIF-- -<?php -if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' ); -?> ---FILE-- -<?php -// Create a resource -$image = tmpfile(); - -// Draw a rectangle -imagerectangle( $image, 0, 0, 50, 50, 2 ); -?> ---EXPECTF-- -Warning: imagerectangle(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagesetthickness_error1.phpt b/ext/gd/tests/imagesetthickness_error1.phpt deleted file mode 100644 index f54270afbc..0000000000 --- a/ext/gd/tests/imagesetthickness_error1.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Testing imagetruecolortopalette(): wrong types for first parameter ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php -$resource = tmpfile(); - -imagesetthickness('string', 5); -imagesetthickness(array(), 5); -imagesetthickness($resource, 5); -?> ---EXPECTF-- -Warning: imagesetthickness() expects parameter 1 to be resource, %s given in %s on line %d - -Warning: imagesetthickness() expects parameter 1 to be resource, array given in %s on line %d - -Warning: imagesetthickness(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagestring_error2.phpt b/ext/gd/tests/imagestring_error2.phpt deleted file mode 100644 index e4b22651c6..0000000000 --- a/ext/gd/tests/imagestring_error2.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Testing error on non-image resource parameter 1 of imagestring() of GD library ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php - -$result = imagestring(tmpfile(), 1, 5, 5, 'String', 1); - -?> ---EXPECTF-- -Warning: imagestring(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagestringup_error2.phpt b/ext/gd/tests/imagestringup_error2.phpt deleted file mode 100644 index 871dd54fde..0000000000 --- a/ext/gd/tests/imagestringup_error2.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Testing error on non-image resource parameter 1 of imagestringup() of GD library ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); -?> ---FILE-- -<?php - -$result = imagestringup(tmpfile(), 1, 5, 5, 'String', 1); - -?> ---EXPECTF-- -Warning: imagestringup(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagetruecolortopalette_error1.phpt b/ext/gd/tests/imagetruecolortopalette_error1.phpt deleted file mode 100644 index 3418449c01..0000000000 --- a/ext/gd/tests/imagetruecolortopalette_error1.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Testing imagetruecolortopalette(): wrong parameters for parameter 1 ---CREDITS-- -Rafael Dohms <rdohms [at] gmail [dot] com> ---SKIPIF-- -<?php - if (!extension_loaded("gd")) die("skip GD not present"); - if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); -?> ---FILE-- -<?php -$resource = tmpfile(); - -imagetruecolortopalette($resource, true, 2); -imagetruecolortopalette('string', true, 2); -imagetruecolortopalette(array(), true, 2); -imagetruecolortopalette(null, true, 2); -?> ---EXPECTF-- -Warning: imagetruecolortopalette(): supplied resource is not a valid Image resource in %s on line %d - -Warning: imagetruecolortopalette() expects parameter 1 to be resource, %s given in %s on line %d - -Warning: imagetruecolortopalette() expects parameter 1 to be resource, array given in %s on line %d - -Warning: imagetruecolortopalette() expects parameter 1 to be resource, null given in %s on line %d diff --git a/ext/gd/tests/imagetruecolortopalette_error3.phpt b/ext/gd/tests/imagetruecolortopalette_error3.phpt index d89bbcb31b..40dc306116 100644 --- a/ext/gd/tests/imagetruecolortopalette_error3.phpt +++ b/ext/gd/tests/imagetruecolortopalette_error3.phpt @@ -9,20 +9,14 @@ Rafael Dohms <rdohms [at] gmail [dot] com> ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $image = imagecreatetruecolor(50, 50); -$resource = tmpfile(); -imagetruecolortopalette($image, true, 'string'); -imagetruecolortopalette($image, true, $resource); -imagetruecolortopalette($image, true, array()); -imagetruecolortopalette($image, true, null); +trycatch_dump( + fn() => imagetruecolortopalette($image, true, null) +); ?> ---EXPECTF-- -Warning: imagetruecolortopalette() expects parameter 3 to be int, string given in %s on line %d - -Warning: imagetruecolortopalette() expects parameter 3 to be int, resource given in %s on line %d - -Warning: imagetruecolortopalette() expects parameter 3 to be int, array given in %s on line %d - -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s on line %d +--EXPECT-- +!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 diff --git a/ext/gd/tests/imagetruecolortopalette_error4.phpt b/ext/gd/tests/imagetruecolortopalette_error4.phpt index 2db042e89f..055fc657b2 100644 --- a/ext/gd/tests/imagetruecolortopalette_error4.phpt +++ b/ext/gd/tests/imagetruecolortopalette_error4.phpt @@ -9,13 +9,16 @@ Rafael Dohms <rdohms [at] gmail [dot] com> ?> --FILE-- <?php +require __DIR__ . '/func.inc'; + $image = imagecreatetruecolor(50, 50); -imagetruecolortopalette($image, true, 0); -imagetruecolortopalette($image, true, -1); +trycatch_dump( + fn() => imagetruecolortopalette($image, true, 0), + fn() => imagetruecolortopalette($image, true, -1) +); ?> ---EXPECTF-- -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s line %d - -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s line %d +--EXPECT-- +!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 +!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 diff --git a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt index fc5d238f41..cce38a63df 100644 --- a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt @@ -8,15 +8,14 @@ if (!isset($support['WBMP Support']) || $support['WBMP Support'] === false) { print 'skip wbmp support not available'; } ?> ---CLEAN-- -$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); -foreach (glob($tempdir . "/test*") as $file ) { unlink($file); } -rmdir($tempdir); --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagewbmp($image, "./foo\0bar")); +try { + imagewbmp($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: imagewbmp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d -bool(false) +--EXPECT-- +Invalid 2nd parameter, filename must not contain null bytes diff --git a/ext/gd/tests/imagewebp_nullbyte_injection.phpt b/ext/gd/tests/imagewebp_nullbyte_injection.phpt index d778d0a379..82e45aca02 100644 --- a/ext/gd/tests/imagewebp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagewebp_nullbyte_injection.phpt @@ -8,15 +8,14 @@ if (!isset($support['WebP Support']) || $support['WebP Support'] === false) { print 'skip webp support not available'; } ?> ---CLEAN-- -$tempdir = sprintf("%s/%s", sys_get_temp_dir(), preg_replace("~\.php$~", null, __FILE__)); -foreach (glob($tempdir . "/test*") as $file ) { unlink($file); } -rmdir($tempdir); --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagewebp($image, "./foo\0bar")); +try { + imagewebp($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: imagewebp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d -bool(false) +--EXPECT-- +Invalid 2nd parameter, filename must not contain null bytes diff --git a/ext/gd/tests/imagexbm_nullbyte_injection.phpt b/ext/gd/tests/imagexbm_nullbyte_injection.phpt index b485315064..a24aa3c007 100644 --- a/ext/gd/tests/imagexbm_nullbyte_injection.phpt +++ b/ext/gd/tests/imagexbm_nullbyte_injection.phpt @@ -7,10 +7,11 @@ if(!extension_loaded('gd')) die('skip gd extension not available'); --FILE-- <?php $image = imagecreate(1,1);// 1px image -var_dump(imagexbm($image, "./foo\0bar")); +try { + imagexbm($image, "./foo\0bar"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> -===DONE=== --EXPECTF-- -Warning: imagexbm() expects parameter 2 to be a valid path, string given in %s on line %d -NULL -===DONE=== +imagexbm() expects parameter 2 to be a valid path, string given diff --git a/ext/gd/tests/jpeg2wbmp_error1.phpt b/ext/gd/tests/jpeg2wbmp_error1.phpt deleted file mode 100644 index e8e0a7cf2e..0000000000 --- a/ext/gd/tests/jpeg2wbmp_error1.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Test jpeg2wbmp() function : wrong threshold value param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('jpeg2wbmp')) { - die('skip jpeg2wbmp function is not available'); -} -?> ---FILE-- -<?php -// Create a blank image and add some text -$im = imagecreatetruecolor(120, 20); -$text_color = imagecolorallocate($im, 255, 255, 255); -imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); - -$file = __DIR__ .'/simpletext.jpg'; -$file2 = __DIR__ .'/simpletext.wbmp'; - -// Save the image as 'simpletext.jpg' -imagejpeg($im, $file); - -// Free up memory -imagedestroy($im); - -jpeg2wbmp($file, $file2, 20, 120, 9); -jpeg2wbmp($file, $file2, 20, 120, -1); -?> ---EXPECTF-- -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Invalid threshold value '9' in %s on line %d - -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Invalid threshold value '-1' in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext.jpg'); -unlink(__DIR__ .'/simpletext.wbmp'); -?> diff --git a/ext/gd/tests/jpeg2wbmp_error2-mb.phpt b/ext/gd/tests/jpeg2wbmp_error2-mb.phpt deleted file mode 100644 index 6c4019a935..0000000000 --- a/ext/gd/tests/jpeg2wbmp_error2-mb.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Test jpeg2wbmp() function : wrong origin filename param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('jpeg2wbmp')) { - die('skip jpeg2wbmp function is not available'); -} -?> ---FILE-- -<?php -$file = __DIR__ .'/simpletext私はガラスを食べられます.wbmp'; -jpeg2wbmp('', $file, 20, 120, 8); -jpeg2wbmp(null, $file, 20, 120, 8); -jpeg2wbmp(false, $file, 20, 120, 8); -?> ---EXPECTF-- -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d - -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d - -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext私はガラスを食べられます.wbmp'); -?> diff --git a/ext/gd/tests/jpeg2wbmp_error2.phpt b/ext/gd/tests/jpeg2wbmp_error2.phpt deleted file mode 100644 index 7ddc151d78..0000000000 --- a/ext/gd/tests/jpeg2wbmp_error2.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Test jpeg2wbmp() function : wrong origin filename param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('jpeg2wbmp')) { - die('skip jpeg2wbmp function is not available'); -} -?> ---FILE-- -<?php -$file = __DIR__ .'/simpletext.wbmp'; -jpeg2wbmp('', $file, 20, 120, 8); -jpeg2wbmp(null, $file, 20, 120, 8); -jpeg2wbmp(false, $file, 20, 120, 8); -?> ---EXPECTF-- -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d - -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d - -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext.wbmp'); -?> diff --git a/ext/gd/tests/jpeg2wbmp_error3.phpt b/ext/gd/tests/jpeg2wbmp_error3.phpt deleted file mode 100644 index 1d4c82b06e..0000000000 --- a/ext/gd/tests/jpeg2wbmp_error3.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -Test jpeg2wbmp() function : wrong destination filename param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('jpeg2wbmp')) { - die('skip jpeg2wbmp function is not available'); -} -?> ---FILE-- -<?php -// Create a blank image and add some text -$im = imagecreatetruecolor(120, 20); -$text_color = imagecolorallocate($im, 255, 255, 255); -imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); - -$file = __DIR__ .'/simpletext.jpg'; - -// Save the image as 'simpletext.jpg' -imagejpeg($im, $file); - -// Free up memory -imagedestroy($im); - -jpeg2wbmp($file, '', 20, 120, 8); -jpeg2wbmp($file, null, 20, 120, 8); -jpeg2wbmp($file, false, 20, 120, 8); -?> ---EXPECTF-- -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for writing in %s on line %d - -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for writing in %s on line %d - -Deprecated: Function jpeg2wbmp() is deprecated in %s on line %d - -Warning: jpeg2wbmp(): Unable to open '' for writing in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext.jpg'); -?> diff --git a/ext/gd/tests/lines.phpt b/ext/gd/tests/lines.phpt index dda8497222..9401b6c82d 100644 --- a/ext/gd/tests/lines.phpt +++ b/ext/gd/tests/lines.phpt @@ -9,10 +9,6 @@ imageline no AA $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); -// Wrong argument count -imageline($im, 0,0, 5,5); - - // Horizontal line imageline($im, 0,5, 5,5, 0x00ff00); @@ -105,7 +101,6 @@ if ($p3) { ?> --EXPECTF-- -Warning: imageline() expects exactly 6 parameters, 5 given in %s on line %d Horizontal: ok Vertical: ok Diagonal: ok diff --git a/ext/gd/tests/png2wbmp_error1-mb.phpt b/ext/gd/tests/png2wbmp_error1-mb.phpt deleted file mode 100644 index ac0753fb6c..0000000000 --- a/ext/gd/tests/png2wbmp_error1-mb.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Test png2wbmp() function : wrong threshold value param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('png2wbmp')) { - die('skip png2wbmp function is not available'); -} -?> ---FILE-- -<?php -// Create a blank image and add some text -$im = imagecreatetruecolor(120, 20); -$text_color = imagecolorallocate($im, 255, 255, 255); -imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); - -$file = __DIR__ .'/simpletext私はガラスを食べられます.png'; -$file2 = __DIR__ .'/simpletext私はガラスを食べられます.wbmp'; - -// Save the image as 'simpletext.png' -imagepng($im, $file); - -// Free up memory -imagedestroy($im); - -png2wbmp($file, $file2, 20, 120, 9); -png2wbmp($file, $file2, 20, 120, -1); -?> ---EXPECTF-- -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Invalid threshold value '9' in %s on line %d - -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Invalid threshold value '-1' in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext私はガラスを食べられます.png'); -unlink(__DIR__ .'/simpletext私はガラスを食べられます.wbmp'); -?> diff --git a/ext/gd/tests/png2wbmp_error1.phpt b/ext/gd/tests/png2wbmp_error1.phpt deleted file mode 100644 index 5805dfa7a0..0000000000 --- a/ext/gd/tests/png2wbmp_error1.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Test png2wbmp() function : wrong threshold value param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('png2wbmp')) { - die('skip png2wbmp function is not available'); -} -?> ---FILE-- -<?php -// Create a blank image and add some text -$im = imagecreatetruecolor(120, 20); -$text_color = imagecolorallocate($im, 255, 255, 255); -imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); - -$file = __DIR__ .'/simpletext.png'; -$file2 = __DIR__ .'/simpletext.wbmp'; - -// Save the image as 'simpletext.png' -imagepng($im, $file); - -// Free up memory -imagedestroy($im); - -png2wbmp($file, $file2, 20, 120, 9); -png2wbmp($file, $file2, 20, 120, -1); -?> ---EXPECTF-- -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Invalid threshold value '9' in %s on line %d - -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Invalid threshold value '-1' in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext.png'); -unlink(__DIR__ .'/simpletext.wbmp'); -?> diff --git a/ext/gd/tests/png2wbmp_error2.phpt b/ext/gd/tests/png2wbmp_error2.phpt deleted file mode 100644 index 3bfff05891..0000000000 --- a/ext/gd/tests/png2wbmp_error2.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Test png2wbmp() function : wrong origin filename param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('png2wbmp')) { - die('skip png2wbmp function is not available'); -} -?> ---FILE-- -<?php -$file = __DIR__ .'/simpletext.wbmp'; -png2wbmp('', $file, 20, 120, 8); -png2wbmp(null, $file, 20, 120, 8); -png2wbmp(false, $file, 20, 120, 8); -?> ---EXPECTF-- -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Unable to open '' for reading in %s on line %d - -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Unable to open '' for reading in %s on line %d - -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Unable to open '' for reading in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext.wbmp'); -?> diff --git a/ext/gd/tests/png2wbmp_error3.phpt b/ext/gd/tests/png2wbmp_error3.phpt deleted file mode 100644 index 8bf0aa25bb..0000000000 --- a/ext/gd/tests/png2wbmp_error3.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -Test png2wbmp() function : wrong destination filename param ---CREDITS-- -Levi Fukumori <levi [at] fukumori [dot] com [dot] br> -#testfest PHPSP on 2009-06-20 ---SKIPIF-- -<?php -if(!extension_loaded('gd')) { - die('skip gd extension is not loaded'); -} -if(!function_exists('png2wbmp')) { - die('skip png2wbmp function is not available'); -} -?> ---FILE-- -<?php -// Create a blank image and add some text -$im = imagecreatetruecolor(120, 20); -$text_color = imagecolorallocate($im, 255, 255, 255); -imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); - -$file = __DIR__ .'/simpletext.png'; - -// Save the image as 'simpletext.png' -imagepng($im, $file); - -// Free up memory -imagedestroy($im); - -png2wbmp($file, '', 20, 120, 8); -png2wbmp($file, null, 20, 120, 8); -png2wbmp($file, false, 20, 120, 8); -?> ---EXPECTF-- -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Unable to open '' for writing in %s on line %d - -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Unable to open '' for writing in %s on line %d - -Deprecated: Function png2wbmp() is deprecated in %s on line %d - -Warning: png2wbmp(): Unable to open '' for writing in %s on line %d ---CLEAN-- -<?php -unlink(__DIR__ .'/simpletext.png'); -?> |