Permalink
Browse files

Separating and complementing imageistruecolor and imagetruecolortopal…

…ette tests
  • Loading branch information...
1 parent c16d5d9 commit 563b6ba594543e6e9091fc3bc050794d406b80b1 @rdohms rdohms committed Jul 20, 2009
View
17 ext/gd/tests/imageistruecolor_basic.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Testing imageistruecolor() of GD library
+--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);
+
+var_dump(imageistruecolor($image));
+?>
+--EXPECT--
+bool(true)
View
24 ext/gd/tests/imageistruecolor_error1.phpt
@@ -0,0 +1,24 @@
+--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(): supplied argument is not a valid Image resource in %s on line %d
+
+Warning: imageistruecolor(): supplied resource is not a valid Image resource in %s on line %d
+
+Warning: imageistruecolor(): supplied argument is not a valid Image resource in %s on line %d
View
31 ext/gd/tests/imagetruecolortopalette_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Testing imagetruecolortopalette() of GD library
+--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(150, 150);
+
+$a = imagecolorallocate($image,255,0,255);
+$b = imagecolorallocate($image,0,255,255);
+
+$half = imagefilledarc ( $image, 75, 75, 70, 70, 0, 180, $a, IMG_ARC_PIE );
+$half2 = imagefilledarc ( $image, 75, 55, 80, 70, 0, -180, $b, IMG_ARC_PIE );
+
+var_dump(imagetruecolortopalette($image, true, 2));
+
+ob_start();
+imagepng($image, null, 9);
+$img = ob_get_contents();
+ob_end_clean();
+
+echo md5(base64_encode($img));
+?>
+--EXPECT--
+bool(true)
+0843f63ab2f9fddedd69b0b421686bc5
View
26 ext/gd/tests/imagetruecolortopalette_error1.phpt
@@ -0,0 +1,26 @@
+--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(): supplied argument is not a valid Image resource in %s on line %d
+
+Warning: imagetruecolortopalette(): supplied argument is not a valid Image resource in %s on line %d
+
+Warning: imagetruecolortopalette(): supplied argument is not a valid Image resource in %s on line %d
View
23 ext/gd/tests/imagetruecolortopalette_error2.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Testing imagetruecolortopalette(): wrong parameters for parameter 2
+--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(50, 50);
+$resource = tmpfile();
+
+$a = imagetruecolortopalette($image, $resource, 2);
+$b = imagetruecolortopalette($image, array(), 2);
+
+var_dump($a, $b);
+//Both will return true in 5.2.x due to lack of parameter validation
+?>
+--EXPECTF--
+bool(true)
+bool(true)
View
26 ext/gd/tests/imagetruecolortopalette_error3.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Testing imagetruecolortopalette(): wrong parameters for parameter 3
+--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(50, 50);
+$resource = tmpfile();
+
+imagetruecolortopalette($image, true, 'string');
+imagetruecolortopalette($image, true, $resource);
+imagetruecolortopalette($image, true, array());
+imagetruecolortopalette($image, true, null);
+
+?>
+--EXPECTF--
+Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d
+
+Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d
+
+Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d

0 comments on commit 563b6ba

Please sign in to comment.