]> granicus.if.org Git - php/commitdiff
Separating and complementing imageistruecolor and imagetruecolortopalette tests
authorRafael Machado Dohms <rdohms@php.net>
Mon, 20 Jul 2009 03:47:29 +0000 (03:47 +0000)
committerRafael Machado Dohms <rdohms@php.net>
Mon, 20 Jul 2009 03:47:29 +0000 (03:47 +0000)
ext/gd/tests/imageistruecolor_basic.phpt [new file with mode: 0644]
ext/gd/tests/imageistruecolor_error1.phpt [new file with mode: 0644]
ext/gd/tests/imagetruecolortopalette_basic.phpt [new file with mode: 0644]
ext/gd/tests/imagetruecolortopalette_error1.phpt [new file with mode: 0644]
ext/gd/tests/imagetruecolortopalette_error2.phpt [new file with mode: 0644]
ext/gd/tests/imagetruecolortopalette_error3.phpt [new file with mode: 0644]

diff --git a/ext/gd/tests/imageistruecolor_basic.phpt b/ext/gd/tests/imageistruecolor_basic.phpt
new file mode 100644 (file)
index 0000000..a78aaa4
--- /dev/null
@@ -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)
\ No newline at end of file
diff --git a/ext/gd/tests/imageistruecolor_error1.phpt b/ext/gd/tests/imageistruecolor_error1.phpt
new file mode 100644 (file)
index 0000000..cf5c775
--- /dev/null
@@ -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
\ No newline at end of file
diff --git a/ext/gd/tests/imagetruecolortopalette_basic.phpt b/ext/gd/tests/imagetruecolortopalette_basic.phpt
new file mode 100644 (file)
index 0000000..b0a0394
--- /dev/null
@@ -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
\ No newline at end of file
diff --git a/ext/gd/tests/imagetruecolortopalette_error1.phpt b/ext/gd/tests/imagetruecolortopalette_error1.phpt
new file mode 100644 (file)
index 0000000..d3c4f0b
--- /dev/null
@@ -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
\ No newline at end of file
diff --git a/ext/gd/tests/imagetruecolortopalette_error2.phpt b/ext/gd/tests/imagetruecolortopalette_error2.phpt
new file mode 100644 (file)
index 0000000..5ba8882
--- /dev/null
@@ -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)
\ No newline at end of file
diff --git a/ext/gd/tests/imagetruecolortopalette_error3.phpt b/ext/gd/tests/imagetruecolortopalette_error3.phpt
new file mode 100644 (file)
index 0000000..803c1e4
--- /dev/null
@@ -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
\ No newline at end of file