summaryrefslogtreecommitdiff
path: root/ext/gd
diff options
context:
space:
mode:
authorZoe Slattery <zoe@php.net>2008-06-10 18:31:37 +0000
committerZoe Slattery <zoe@php.net>2008-06-10 18:31:37 +0000
commitbc84bcc19c5bfbd58cdcb6dfbbc4619b01c9e151 (patch)
tree5781bb35d6fd5ef16aad875e176bb32ac6339ac9 /ext/gd
parentbfda5b1b584c85c84d876d59a2f1cca6bffa5f81 (diff)
downloadphp-git-bc84bcc19c5bfbd58cdcb6dfbbc4619b01c9e151.tar.gz
Written by Sanjay Mantoor and reviewed by Pierre.
Diffstat (limited to 'ext/gd')
-rw-r--r--ext/gd/tests/gd_info_error.phpt38
-rw-r--r--ext/gd/tests/image_type_to_mime_type_error.phpt35
-rw-r--r--ext/gd/tests/image_type_to_mime_type_variation2.phpt119
3 files changed, 192 insertions, 0 deletions
diff --git a/ext/gd/tests/gd_info_error.phpt b/ext/gd/tests/gd_info_error.phpt
new file mode 100644
index 0000000000..15a26e4a49
--- /dev/null
+++ b/ext/gd/tests/gd_info_error.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test gd_info() function : error conditions - with more than expected number of arguments
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+ die('skip gd extension is not loaded');
+}
+if(!function_exists('gd_info')) {
+ die('skip gd_info function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype : array gd_info()
+ * Description: Retrieve information about the currently installed GD library
+ * Source code: ext/gd/gd.c
+ */
+$extra_arg_number = 10;
+$extra_arg_string = "Hello";
+
+echo "*** Testing gd_info() : error conditions ***\n";
+
+echo "\n-- Testing gd_info() function with more than expected number of arguments --\n";
+var_dump(gd_info($extra_arg_number));
+var_dump(gd_info($extra_arg_string, $extra_arg_number));
+?>
+===DONE===
+--EXPECTF--
+*** Testing gd_info() : error conditions ***
+
+-- Testing gd_info() function with more than expected number of arguments --
+
+Warning: gd_info() expects exactly 0 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: gd_info() expects exactly 0 parameters, 2 given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/image_type_to_mime_type_error.phpt b/ext/gd/tests/image_type_to_mime_type_error.phpt
new file mode 100644
index 0000000000..6ffdd43171
--- /dev/null
+++ b/ext/gd/tests/image_type_to_mime_type_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test image_type_to_mime_type() function : error conditions - Pass incorrect number of arguments
+--FILE--
+<?php
+/* Prototype : proto 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
+ */
+
+$imagetype = IMAGETYPE_GIF;
+$extra_arg = 10;
+echo "*** Testing image_type_to_mime_type() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing image_type_to_mime_type() function with Zero arguments --\n";
+var_dump( image_type_to_mime_type() );
+
+//Test image_type_to_mime_type with one more than the expected number of arguments
+echo "\n-- Testing image_type_to_mime_type() function with more than expected no. of arguments --\n";
+var_dump( image_type_to_mime_type($imagetype, $extra_arg) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing image_type_to_mime_type() : error conditions ***
+
+-- Testing image_type_to_mime_type() function with Zero arguments --
+
+Warning: image_type_to_mime_type() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing image_type_to_mime_type() function with more than expected no. of arguments --
+
+Warning: image_type_to_mime_type() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/image_type_to_mime_type_variation2.phpt b/ext/gd/tests/image_type_to_mime_type_variation2.phpt
new file mode 100644
index 0000000000..159e7cf53f
--- /dev/null
+++ b/ext/gd/tests/image_type_to_mime_type_variation2.phpt
@@ -0,0 +1,119 @@
+--TEST--
+Test image_type_to_mime_type() function : usage variations - Pass decimal, octal, and hexadecimal values as imagetype
+--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);
+$values = array (
+ //Decimal values
+ 0,
+ 1,
+ 12345,
+ -12345,
+
+ //Octal values
+ 02,
+ 010,
+ 030071,
+ -030071,
+
+ //Hexadecimal values
+ 0x0,
+ 0x1,
+ 0xABCD,
+ -0xABCD
+);
+
+// loop through each element of the array for imagetype
+$iterator = 1;
+foreach($values as $value) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump( image_type_to_mime_type($value) );
+ $iterator++;
+};
+?>
+===DONE===
+--EXPECT--
+*** Testing image_type_to_mime_type() : usage variations ***
+
+-- Iteration 1 --
+string(24) "application/octet-stream"
+
+-- Iteration 2 --
+string(9) "image/gif"
+
+-- Iteration 3 --
+string(24) "application/octet-stream"
+
+-- Iteration 4 --
+string(24) "application/octet-stream"
+
+-- Iteration 5 --
+string(10) "image/jpeg"
+
+-- Iteration 6 --
+string(10) "image/tiff"
+
+-- Iteration 7 --
+string(24) "application/octet-stream"
+
+-- Iteration 8 --
+string(24) "application/octet-stream"
+
+-- Iteration 9 --
+string(24) "application/octet-stream"
+
+-- Iteration 10 --
+string(9) "image/gif"
+
+-- Iteration 11 --
+string(24) "application/octet-stream"
+
+-- Iteration 12 --
+string(24) "application/octet-stream"
+===DONE===
+--UEXPECT--
+*** Testing image_type_to_mime_type() : usage variations ***
+
+-- Iteration 1 --
+unicode(24) "application/octet-stream"
+
+-- Iteration 2 --
+unicode(9) "image/gif"
+
+-- Iteration 3 --
+unicode(24) "application/octet-stream"
+
+-- Iteration 4 --
+unicode(24) "application/octet-stream"
+
+-- Iteration 5 --
+unicode(10) "image/jpeg"
+
+-- Iteration 6 --
+unicode(10) "image/tiff"
+
+-- Iteration 7 --
+unicode(24) "application/octet-stream"
+
+-- Iteration 8 --
+unicode(24) "application/octet-stream"
+
+-- Iteration 9 --
+unicode(24) "application/octet-stream"
+
+-- Iteration 10 --
+unicode(9) "image/gif"
+
+-- Iteration 11 --
+unicode(24) "application/octet-stream"
+
+-- Iteration 12 --
+unicode(24) "application/octet-stream"
+===DONE===