summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandy wharmby <wharmby@php.net>2009-01-22 13:27:32 +0000
committerandy wharmby <wharmby@php.net>2009-01-22 13:27:32 +0000
commitbe84cfa32729c251ed5350c9f226809369d34b66 (patch)
tree15c70fc437b306e85f907d4293fd68d2f7b29b90
parentaa3e1f615823df29289224652055a719c6268d2d (diff)
downloadphp-git-be84cfa32729c251ed5350c9f226809369d34b66.tar.gz
New image tests. Tested on Windows, LInux and Linux 64 bit
-rw-r--r--ext/gd/tests/image_type_to_mime_type_variation3.phpt76
-rw-r--r--ext/gd/tests/image_type_to_mime_type_variation4.phpt29
-rw-r--r--ext/gd/tests/imagecolorallocate_basic.phpt35
-rw-r--r--ext/gd/tests/imagecolorallocate_error.phpt49
-rw-r--r--ext/gd/tests/imagecolorallocate_variation1.phpt267
-rw-r--r--ext/gd/tests/imagecolorallocate_variation2.phpt214
-rw-r--r--ext/gd/tests/imagecolorallocate_variation3.phpt214
-rw-r--r--ext/gd/tests/imagecolorallocate_variation4.phpt213
-rw-r--r--ext/gd/tests/imagecolorallocate_variation5.phpt90
-rw-r--r--ext/gd/tests/imagecolorallocate_variation6.phpt56
-rw-r--r--ext/gd/tests/imagecolorstotal_basic.phpt36
-rw-r--r--ext/gd/tests/imagecolorstotal_error.phpt54
-rw-r--r--ext/gd/tests/php.gifbin0 -> 2523 bytes
13 files changed, 1333 insertions, 0 deletions
diff --git a/ext/gd/tests/image_type_to_mime_type_variation3.phpt b/ext/gd/tests/image_type_to_mime_type_variation3.phpt
new file mode 100644
index 0000000000..a1c042a060
--- /dev/null
+++ b/ext/gd/tests/image_type_to_mime_type_variation3.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Test image_type_to_mime_type() function : usage variations - Pass equivalent imagetype constant integer values
+--FILE--
+<?php
+/* Prototype : string image_type_to_mime_type(int imagetype)
+ * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
+ * Source code: ext/standard/image.c
+ */
+
+echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
+
+//There are 17 imagetypes
+$number_of_imagetypes = 17;
+
+$iterator = 1;
+for($imagetype = 1; $imagetype<=$number_of_imagetypes; $imagetype++) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump( image_type_to_mime_type($imagetype) );
+ $iterator++;
+}
+?>
+===DONE===
+--EXPECTREGEX--
+\*\*\* Testing image_type_to_mime_type\(\) : usage variations \*\*\*
+
+-- Iteration 1 --
+string\(9\) "image\/gif"
+
+-- Iteration 2 --
+string\(10\) "image\/jpeg"
+
+-- Iteration 3 --
+string\(9\) "image\/png"
+
+-- Iteration 4 --
+string\(29\) "application\/x-shockwave-flash"
+
+-- Iteration 5 --
+string\(9\) "image\/psd"
+
+-- Iteration 6 --
+string\(9\) "image\/bmp"
+
+-- Iteration 7 --
+string\(10\) "image\/tiff"
+
+-- Iteration 8 --
+string\(10\) "image\/tiff"
+
+-- Iteration 9 --
+string\(24\) "application\/octet-stream"
+
+-- Iteration 10 --
+string\(9\) "image\/jp2"
+
+-- Iteration 11 --
+string\(24\) "application\/octet-stream"
+
+-- Iteration 12 --
+string\(24\) "application\/octet-stream"
+
+-- Iteration 13 --
+string\(2[49]\) "application\/(x-shockwave-flash|octet-stream)"
+
+-- Iteration 14 --
+string\(9\) "image\/iff"
+
+-- Iteration 15 --
+string\(18\) "image\/vnd.wap.wbmp"
+
+-- Iteration 16 --
+string\(9\) "image\/xbm"
+
+-- Iteration 17 --
+string\(24\) "image\/vnd.microsoft.icon"
+===DONE===
diff --git a/ext/gd/tests/image_type_to_mime_type_variation4.phpt b/ext/gd/tests/image_type_to_mime_type_variation4.phpt
new file mode 100644
index 0000000000..a67bb86a69
--- /dev/null
+++ b/ext/gd/tests/image_type_to_mime_type_variation4.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test image_type_to_mime_type() function : usage variations - Passing IMAGETYPE_ICO and IMAGETYPE_SWC
+--SKIPIF--
+<?php
+ if (!defined("IMAGETYPE_SWC") || !defined("IMAGETYPE_ICO") || !extension_loaded('zlib')) {
+ die("skip zlib extension is not available or IMAGETYPE_SWC/IMAGETYPE_ICO is not defined ");
+ }
+?>
+--FILE--
+<?php
+/* Prototype : string image_type_to_mime_type(int imagetype)
+ * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
+ * Source code: ext/standard/image.c
+ */
+
+
+echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
+
+error_reporting(E_ALL ^ E_NOTICE);
+
+var_dump( image_type_to_mime_type(IMAGETYPE_ICO) );
+var_dump( image_type_to_mime_type(IMAGETYPE_SWC) );
+?>
+===DONE===
+--EXPECT--
+*** Testing image_type_to_mime_type() : usage variations ***
+string(24) "image/vnd.microsoft.icon"
+string(29) "application/x-shockwave-flash"
+===DONE===
diff --git a/ext/gd/tests/imagecolorallocate_basic.phpt b/ext/gd/tests/imagecolorallocate_basic.phpt
new file mode 100644
index 0000000000..25b2821485
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_basic.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test imagecolorallocate() function : basic functionality
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+ die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : basic functionality ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+// Calling imagecolorallocate() with all possible arguments
+var_dump( imagecolorallocate($im, 255, 0, 0) );
+var_dump( imagecolorallocate($im, 0, 255, 0) );
+var_dump( imagecolorallocate($im, 0, 0, 255) );
+var_dump( imagecolorallocate($im, 255, 255, 255) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : basic functionality ***
+int(16711680)
+int(65280)
+int(255)
+int(16777215)
+===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocate_error.phpt b/ext/gd/tests/imagecolorallocate_error.phpt
new file mode 100644
index 0000000000..6c685b2c98
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_error.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Test imagecolorallocate() function : error conditions
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+$red = 10;
+$green = 10;
+$blue = 10;
+$extra_arg = 10;
+$im = imagecreate(200, 200);
+
+echo "*** Testing imagecolorallocate() : error conditions ***\n";
+
+//Test imagecolorallocate with one more than the expected number of arguments
+echo "\n-- Testing imagecolorallocate() function with more than expected no. of arguments --\n";
+var_dump( imagecolorallocate($im, $red, $green, $blue, $extra_arg) );
+
+// Testing imagecolorallocate with one less than the expected number of arguments
+echo "\n-- Testing imagecolorallocate() function with less than expected no. of arguments --\n";
+var_dump( imagecolorallocate() );
+var_dump( imagecolorallocate($im, $red, $green) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : error conditions ***
+
+-- Testing imagecolorallocate() function with more than expected no. of arguments --
+
+Warning: imagecolorallocate() expects exactly 4 parameters, 5 given in %s on line %d
+NULL
+
+-- Testing imagecolorallocate() function with less than expected no. of arguments --
+
+Warning: imagecolorallocate() expects exactly 4 parameters, 0 given in %s on line %d
+NULL
+
+Warning: imagecolorallocate() expects exactly 4 parameters, 3 given in %s on line %d
+NULL
+===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocate_variation1.phpt b/ext/gd/tests/imagecolorallocate_variation1.phpt
new file mode 100644
index 0000000000..552a0fc084
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_variation1.phpt
@@ -0,0 +1,267 @@
+--TEST--
+Test imagecolorallocate() function : usage variations - passing different data types to first argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$red = 10;
+$green = 10;
+$blue = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -12345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 10.1234567e10' => 10.1234567e10,
+ 'float 10.7654321E-10' => 10.7654321E-10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ "file resource" => $fp
+);
+
+// loop through each element of the array for im
+foreach($values as $key => $value) {
+ echo "\n-- $key --\n";
+ var_dump( imagecolorallocate($value, $red, $green, $blue) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+-- int 0 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+-- int 1 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+-- int 12345 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+-- int -12345 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+-- float 10.5 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+-- float -10.5 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+-- float 10.1234567e10 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+-- float 10.7654321E-10 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+-- float .5 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+-- empty array --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+-- int indexed array --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+-- associative array --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+-- nested arrays --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+-- uppercase NULL --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+-- lowercase null --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+-- lowercase true --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+-- lowercase false --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+-- uppercase TRUE --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+-- uppercase FALSE --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+-- empty string DQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+-- empty string SQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+-- string DQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+-- string SQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+-- mixed case string --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+-- heredoc --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+-- instance of classWithToString --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+-- instance of classWithoutToString --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+-- undefined var --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+-- unset var --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+-- file resource --
+
+Warning: imagecolorallocate(): supplied resource is not a valid Image resource in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/gd/tests/imagecolorallocate_variation2.phpt b/ext/gd/tests/imagecolorallocate_variation2.phpt
new file mode 100644
index 0000000000..bd9dc984d1
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_variation2.phpt
@@ -0,0 +1,214 @@
+--TEST--
+Test imagecolorallocate() function : usage variations - passing different data types to second argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+ die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$green = 10;
+$blue = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 10.1234567e10' => 10.1234567e10,
+ 'float 10.7654321E-10' => 10.7654321E-10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ "file resource" => $fp
+);
+// loop through each element of the array for red
+foreach($values as $key => $value) {
+ echo "\n--$key--\n";
+ var_dump( imagecolorallocate($im, $value, $green, $blue) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--float 10.5--
+int(657930)
+
+--float -10.5--
+bool(false)
+
+--float 10.1234567e10--
+bool(false)
+
+--float 10.7654321E-10--
+int(2570)
+
+--float .5--
+int(2570)
+
+--empty array--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+--int indexed array--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+--associative array--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+--nested arrays--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+--uppercase NULL--
+int(2570)
+
+--lowercase null--
+int(2570)
+
+--lowercase true--
+int(68106)
+
+--lowercase false--
+int(2570)
+
+--uppercase TRUE--
+int(68106)
+
+--uppercase FALSE--
+int(2570)
+
+--empty string DQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--empty string SQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--string DQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--string SQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--mixed case string--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--heredoc--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--instance of classWithToString--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, object given in %s on line %d
+NULL
+
+--instance of classWithoutToString--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, object given in %s on line %d
+NULL
+
+--undefined var--
+int(2570)
+
+--unset var--
+int(2570)
+
+--file resource--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, resource given in %s on line %d
+NULL
+===DONE===
diff --git a/ext/gd/tests/imagecolorallocate_variation3.phpt b/ext/gd/tests/imagecolorallocate_variation3.phpt
new file mode 100644
index 0000000000..c48dc29cf5
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_variation3.phpt
@@ -0,0 +1,214 @@
+--TEST--
+Test imagecolorallocate() function : usage variations - passing different data types to third argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+ die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype : imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$red = 10;
+$blue = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 10.1234567e5' => 10.1234567e5,
+ 'float 10.7654321E-5' => 10.7654321E-5,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ "file resource" => $fp
+);
+// loop through each element of the array for red
+foreach($values as $key => $value) {
+ echo "\n--$key--\n";
+ var_dump( imagecolorallocate($im, $red, $value, $blue) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--float 10.5--
+int(657930)
+
+--float -10.5--
+int(652810)
+
+--float 10.1234567e5--
+int(259815690)
+
+--float 10.7654321E-5--
+int(655370)
+
+--float .5--
+int(655370)
+
+--empty array--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d
+NULL
+
+--int indexed array--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d
+NULL
+
+--associative array--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d
+NULL
+
+--nested arrays--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d
+NULL
+
+--uppercase NULL--
+int(655370)
+
+--lowercase null--
+int(655370)
+
+--lowercase true--
+int(655626)
+
+--lowercase false--
+int(655370)
+
+--uppercase TRUE--
+int(655626)
+
+--uppercase FALSE--
+int(655370)
+
+--empty string DQ--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d
+NULL
+
+--empty string SQ--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d
+NULL
+
+--string DQ--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d
+NULL
+
+--string SQ--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d
+NULL
+
+--mixed case string--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d
+NULL
+
+--heredoc--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d
+NULL
+
+--instance of classWithToString--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, object given in %s on line %d
+NULL
+
+--instance of classWithoutToString--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, object given in %s on line %d
+NULL
+
+--undefined var--
+int(655370)
+
+--unset var--
+int(655370)
+
+--file resource--
+
+Warning: imagecolorallocate() expects parameter 3 to be long, resource given in %s on line %d
+NULL
+===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocate_variation4.phpt b/ext/gd/tests/imagecolorallocate_variation4.phpt
new file mode 100644
index 0000000000..328a4cd3b2
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_variation4.phpt
@@ -0,0 +1,213 @@
+--TEST--
+Test imagecolorallocate() function : usage variations - passing different data types to fourth argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+ die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$red = 10;
+$green = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 10.1234567e10' => 10.1234567e10,
+ 'float 10.7654321E-10' => 10.7654321E-10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ "file resource" => $fp
+);
+// loop through each element of the array for red
+foreach($values as $key => $value) {
+ echo "\n--$key--\n";
+ var_dump( imagecolorallocate($im, $red, $green, $value) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--float 10.5--
+int(657930)
+
+--float -10.5--
+int(657910)
+
+--float 10.1234567e10--
+bool(false)
+
+--float 10.7654321E-10--
+int(657920)
+
+--float .5--
+int(657920)
+
+--empty array--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d
+NULL
+
+--int indexed array--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d
+NULL
+
+--associative array--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d
+NULL
+
+--nested arrays--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d
+NULL
+
+--uppercase NULL--
+int(657920)
+
+--lowercase null--
+int(657920)
+
+--lowercase true--
+int(657921)
+
+--lowercase false--
+int(657920)
+
+--uppercase TRUE--
+int(657921)
+
+--uppercase FALSE--
+int(657920)
+
+--empty string DQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d
+NULL
+
+--empty string SQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d
+NULL
+
+--string DQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d
+NULL
+
+--string SQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d
+NULL
+
+--mixed case string--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d
+NULL
+
+--heredoc--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d
+NULL
+
+--instance of classWithToString--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, object given in %s on line %d
+NULL
+
+--instance of classWithoutToString--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, object given in %s on line %d
+NULL
+
+--undefined var--
+int(657920)
+
+--unset var--
+int(657920)
+
+--file resource--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, resource given in %s on line %d
+NULL
+===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocate_variation5.phpt b/ext/gd/tests/imagecolorallocate_variation5.phpt
new file mode 100644
index 0000000000..794abb3d71
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_variation5.phpt
@@ -0,0 +1,90 @@
+--TEST--
+Test imagecolorallocate() function : usage variations - passing octal and hexa-decimal values
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+ die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$red = 10;
+$green = 10;
+$blue = 10;
+
+$values = array(
+ // octal integer data
+ "Octal 000" => 000,
+ "Octal 012" => 012,
+ "Octal -012" => -012,
+ "Octal 0377" => 0377,
+
+ // hexa-decimal integer data
+ "Hexa-decimal 0x0" => 0x0,
+ "Hexa-decimal 0xA" => 0xA,
+ "Hexa-decimal -0xA" => -0xA,
+ "Hexa-decimal 0xFF" => 0xFF,
+);
+
+// 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) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--Octal 000--
+int(2570)
+int(655370)
+int(657920)
+
+--Octal 012--
+int(657930)
+int(657930)
+int(657930)
+
+--Octal -012--
+bool(false)
+int(652810)
+int(657910)
+
+--Octal 0377--
+int(16714250)
+int(720650)
+int(658175)
+
+--Hexa-decimal 0x0--
+int(2570)
+int(655370)
+int(657920)
+
+--Hexa-decimal 0xA--
+int(657930)
+int(657930)
+int(657930)
+
+--Hexa-decimal -0xA--
+bool(false)
+int(652810)
+int(657910)
+
+--Hexa-decimal 0xFF--
+int(16714250)
+int(720650)
+int(658175)
+===DONE===
diff --git a/ext/gd/tests/imagecolorallocate_variation6.phpt b/ext/gd/tests/imagecolorallocate_variation6.phpt
new file mode 100644
index 0000000000..bc939c9799
--- /dev/null
+++ b/ext/gd/tests/imagecolorallocate_variation6.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test imagecolorallocate() function : usage variations - passing RED, GREEN, BLUE values more than 255
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+ die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$values = array(
+ //Decimal integera data
+ "Decimal 256" => 256,
+
+ // octal integer data
+ "Octal 0400" => 0400,
+
+ // hexa-decimal integer data
+ "Hexa-decimal 0x100" => 0x100
+);
+
+// loop through each element of the array for blue
+foreach($values as $key => $value) {
+ echo "\n--$key--\n";
+ //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, $value, $value) );
+ var_dump( imagecolorallocate($im_true_color, $value, $value, $value) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--Decimal 256--
+int(0)
+int(16843008)
+
+--Octal 0400--
+int(0)
+int(16843008)
+
+--Hexa-decimal 0x100--
+int(0)
+int(16843008)
+===DONE===
diff --git a/ext/gd/tests/imagecolorstotal_basic.phpt b/ext/gd/tests/imagecolorstotal_basic.phpt
new file mode 100644
index 0000000000..472a10d864
--- /dev/null
+++ b/ext/gd/tests/imagecolorstotal_basic.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test imagecolorstotal() function : basic functionality
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+
+if(!function_exists('imagecolorstotal') || !function_exists('imagecreatefromgif')) {
+ die('skip imagecolorstotal and imagecreatefromgif functions not available in this build');
+}
+?>
+--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() : basic functionality ***\n";
+
+// Get an image
+$gif = dirname(__FILE__)."/php.gif";
+$im = imagecreatefromgif($gif);
+
+echo 'Total colors in image: ' . imagecolorstotal($im);
+
+// Free image
+imagedestroy($im);
+?>
+
+===DONE===
+--EXPECTF--
+*** Testing imagecolorstotal() : basic functionality ***
+Total colors in image: 128
+===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/imagecolorstotal_error.phpt b/ext/gd/tests/imagecolorstotal_error.phpt
new file mode 100644
index 0000000000..a7f3b95719
--- /dev/null
+++ b/ext/gd/tests/imagecolorstotal_error.phpt
@@ -0,0 +1,54 @@
+--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/php.gif b/ext/gd/tests/php.gif
new file mode 100644
index 0000000000..f352c7308f
--- /dev/null
+++ b/ext/gd/tests/php.gif
Binary files differ