zoe             Tue Jun 10 18:31:38 2008 UTC

  Modified files:              
    /php-src/ext/gd/tests       gd_info_error.phpt 
                                image_type_to_mime_type_error.phpt 
                                image_type_to_mime_type_variation2.phpt 
  Log:
  Written by Sanjay Mantoor and reviewed by Pierre.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/gd_info_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/gd_info_error.phpt
diff -u /dev/null php-src/ext/gd/tests/gd_info_error.phpt:1.2
--- /dev/null   Tue Jun 10 18:31:38 2008
+++ php-src/ext/gd/tests/gd_info_error.phpt     Tue Jun 10 18:31:37 2008
@@ -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
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/image_type_to_mime_type_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/image_type_to_mime_type_error.phpt
diff -u /dev/null php-src/ext/gd/tests/image_type_to_mime_type_error.phpt:1.2
--- /dev/null   Tue Jun 10 18:31:38 2008
+++ php-src/ext/gd/tests/image_type_to_mime_type_error.phpt     Tue Jun 10 
18:31:37 2008
@@ -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
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/image_type_to_mime_type_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/image_type_to_mime_type_variation2.phpt
diff -u /dev/null 
php-src/ext/gd/tests/image_type_to_mime_type_variation2.phpt:1.2
--- /dev/null   Tue Jun 10 18:31:38 2008
+++ php-src/ext/gd/tests/image_type_to_mime_type_variation2.phpt        Tue Jun 
10 18:31:37 2008
@@ -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===



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to