summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorRafael Machado Dohms <rdohms@php.net>2009-07-20 03:47:29 +0000
committerRafael Machado Dohms <rdohms@php.net>2009-07-20 03:47:29 +0000
commit23a423aea0e6d42015b41cdcd3557e66f62ec16e (patch)
tree22797e371512654f905c22bbc6d7080d7e7b9e36 /ext
parent00054412e489c0f3a46ecdacf4ebc6c682111a3f (diff)
downloadphp-git-23a423aea0e6d42015b41cdcd3557e66f62ec16e.tar.gz
Separating and complementing imageistruecolor and imagetruecolortopalette tests
Diffstat (limited to 'ext')
-rw-r--r--ext/gd/tests/imageistruecolor_basic.phpt17
-rw-r--r--ext/gd/tests/imageistruecolor_error1.phpt24
-rw-r--r--ext/gd/tests/imagetruecolortopalette_basic.phpt31
-rw-r--r--ext/gd/tests/imagetruecolortopalette_error1.phpt26
-rw-r--r--ext/gd/tests/imagetruecolortopalette_error2.phpt22
-rw-r--r--ext/gd/tests/imagetruecolortopalette_error3.phpt28
6 files changed, 148 insertions, 0 deletions
diff --git a/ext/gd/tests/imageistruecolor_basic.phpt b/ext/gd/tests/imageistruecolor_basic.phpt
new file mode 100644
index 0000000000..a78aaa46ef
--- /dev/null
+++ b/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) \ 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
index 0000000000..06453b7d31
--- /dev/null
+++ b/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() 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 \ 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
index 0000000000..b0a0394b55
--- /dev/null
+++ b/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 \ 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
index 0000000000..ecafa158b6
--- /dev/null
+++ b/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() 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 \ 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
index 0000000000..cb7004caa8
--- /dev/null
+++ b/ext/gd/tests/imagetruecolortopalette_error2.phpt
@@ -0,0 +1,22 @@
+--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();
+
+imagetruecolortopalette($image, $resource, 2);
+imagetruecolortopalette($image, array(), 2);
+
+?>
+--EXPECTF--
+Warning: imagetruecolortopalette() expects parameter 2 to be boolean, resource given in %s on line %d
+
+Warning: imagetruecolortopalette() expects parameter 2 to be boolean, array given in %s on line %d \ 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
index 0000000000..d65a995014
--- /dev/null
+++ b/ext/gd/tests/imagetruecolortopalette_error3.phpt
@@ -0,0 +1,28 @@
+--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() expects parameter 3 to be long, string given in %s on line %d
+
+Warning: imagetruecolortopalette() expects parameter 3 to be long, resource given in %s on line %d
+
+Warning: imagetruecolortopalette() expects parameter 3 to be long, array given 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