wharmby         Thu Jan 22 22:59:54 2009 UTC

  Modified files:              
    /php-src/ext/standard/tests/image   getimagesize_wbmp.phpt 
                                        getimagesize_tif_mm.phpt 
                                        75x50.wbmp 
                                        getimagesize_variation2.phpt 
                                        getimagesize_xbm.phpt testAPP.jpg 
                                        2x2mm.tif 75x50.xbm blank_file 
                                        getimagesize_variation3.phpt 
                                        getimagesize_error1.phpt 
                                        getimagesize_variation1.phpt 
                                        getimagesize_jpgapp.phpt 
                                        getimagesize_variation4.phpt 
  Log:
  New image tests. Tested on WIndows, Linux and Linux 64 bit
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_wbmp.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_wbmp.phpt
diff -u /dev/null php-src/ext/standard/tests/image/getimagesize_wbmp.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_wbmp.phpt     Thu Jan 22 
22:59:53 2009
@@ -0,0 +1,39 @@
+--TEST--
+GetImageSize() for wbmp format
+--SKIPIF--
+<?php
+       if (!defined("IMAGETYPE_WBMP")) {
+               die("skip wbmp file format is not available");
+       }
+?>
+--FILE--
+<?php
+/* Prototype  : proto array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing getimagesize() : wbmp format ***\n";
+var_dump(getimagesize(dirname(__FILE__) . "/75x50.wbmp", $arr));
+var_dump($arr);
+
+?>
+===DONE===
+--EXPECT--
+*** Testing getimagesize() : wbmp format ***
+array(5) {
+  [0]=>
+  int(75)
+  [1]=>
+  int(50)
+  [2]=>
+  int(15)
+  [3]=>
+  unicode(22) "width="75" height="50""
+  [u"mime"]=>
+  unicode(18) "image/vnd.wap.wbmp"
+}
+array(0) {
+}
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_tif_mm.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_tif_mm.phpt
diff -u /dev/null php-src/ext/standard/tests/image/getimagesize_tif_mm.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_tif_mm.phpt   Thu Jan 22 
22:59:54 2009
@@ -0,0 +1,39 @@
+--TEST--
+GetImageSize() for tiff format with big-endian (aka Motorola, aka MM) ordering
+--SKIPIF--
+<?php
+       if (!defined("IMAGETYPE_TIFF_MM")) {
+               die("skip tiff_mm file format is not available");
+       }
+?>
+--FILE--
+<?php
+/* Prototype  : proto array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing getimagesize() : tiff_mm format ***\n";
+var_dump(getimagesize(dirname(__FILE__) . "/2x2mm.tif", $arr));
+var_dump($arr);
+
+?>
+===DONE===
+--EXPECT--
+*** Testing getimagesize() : tiff_mm format ***
+array(5) {
+  [0]=>
+  int(2)
+  [1]=>
+  int(2)
+  [2]=>
+  int(8)
+  [3]=>
+  unicode(20) "width="2" height="2""
+  [u"mime"]=>
+  unicode(10) "image/tiff"
+}
+array(0) {
+}
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/75x50.wbmp?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/75x50.wbmp
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_variation2.phpt
diff -u /dev/null 
php-src/ext/standard/tests/image/getimagesize_variation2.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_variation2.phpt       Thu Jan 
22 22:59:54 2009
@@ -0,0 +1,167 @@
+--TEST--
+Test getimagesize() function : usage variations  - unexpected type for arg 2
+--SKIPIF--
+<?php
+       if (!defined("IMAGETYPE_JPEG")) {
+               die("skip jpeg format is not available");
+       }
+?>
+--FILE--
+<?php
+/* Prototype  : proto array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ * Alias to functions: 
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing getimagesize() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$imagefile = dirname(__FILE__)."/test1pix.jpg";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+      // int data
+      "0" => 0,
+      "1" => 1,
+      "12345" => 12345,
+      "-2345" => -2345,
+
+      // float data
+      "10.5" => 10.5,
+      "-10.5" => -10.5,
+      "10.1234567e5" => 10.1234567e10,
+      "10.7654321e-5" => 10.7654321E-5,
+      .5,
+
+      // array data
+      "array()" => array(),
+      "array(0)" => array(0),
+      "array(1)" => array(1),
+      "array(1, 2)" => array(1, 2),
+      "array('color' => 'red', 'item' => 'pen')" => array('color' => 'red', 
'item' => 'pen'),
+
+      // null data
+      "NULL" => NULL,
+      "null" => null,
+
+      // boolean data
+      "true" => true,
+      "false" => false,
+      "TRUE" => TRUE,
+      "FALSE" => FALSE,
+
+      // empty data
+      "\"\"" => "",
+      "''" => '',
+
+      // object data
+      "new stdclass()" => new stdclass(),
+
+      // undefined data
+      "undefined_var" => $undefined_var,
+
+      // unset data
+      "unset_var" => $unset_var,
+);
+
+// loop through each element of the array for info
+
+foreach($values as $key => $value) {
+      echo "\n-- Arg value $key --\n";
+      getimagesize($imagefile, $value);
+      var_dump(bin2hex((binary)$value["APP0"]));
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getimagesize() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(%d)
+Error: 8 - Undefined variable: unset_var, %s(%d)
+
+-- Arg value 0 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value 1 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value 12345 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value -2345 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value 10.5 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value -10.5 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value 10.1234567e5 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value 10.7654321e-5 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value 12346 --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value array() --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value array(0) --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value array(1) --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value array(1, 2) --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value array('color' => 'red', 'item' => 'pen') --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value NULL --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value null --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value true --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value false --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value TRUE --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value FALSE --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value "" --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value '' --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value new stdclass() --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value undefined_var --
+unicode(28) "4a46494600010201006000600000"
+
+-- Arg value unset_var --
+unicode(28) "4a46494600010201006000600000"
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_xbm.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_xbm.phpt
diff -u /dev/null php-src/ext/standard/tests/image/getimagesize_xbm.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_xbm.phpt      Thu Jan 22 
22:59:54 2009
@@ -0,0 +1,39 @@
+--TEST--
+GetImageSize() for xbm format
+--SKIPIF--
+<?php
+       if (!defined("IMAGETYPE_XBM")) {
+               die("skip xbm file format is not available");
+       }
+?>
+--FILE--
+<?php
+/* Prototype  : proto array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing getimagesize() : xbm format ***\n";
+var_dump(getimagesize(dirname(__FILE__) . "/75x50.xbm", $arr));
+var_dump($arr);
+
+?>
+===DONE===
+--EXPECT--
+*** Testing getimagesize() : xbm format ***
+array(5) {
+  [0]=>
+  int(75)
+  [1]=>
+  int(50)
+  [2]=>
+  int(16)
+  [3]=>
+  unicode(22) "width="75" height="50""
+  [u"mime"]=>
+  unicode(9) "image/xbm"
+}
+array(0) {
+}
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/testAPP.jpg?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/testAPP.jpg
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/2x2mm.tif?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/2x2mm.tif
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/75x50.xbm?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/75x50.xbm
diff -u /dev/null php-src/ext/standard/tests/image/75x50.xbm:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/75x50.xbm  Thu Jan 22 22:59:54 2009
@@ -0,0 +1,59 @@
+#define Xbitmap_width 75
+#define Xbitmap_height 50
+static unsigned char Xbitmap_bits[] = {
+        0xfd, 0xdb, 0xf5, 0xbf, 0xef, 0x7b, 0xbb, 0xae, 0xaa, 
+        0x07, 0xff, 0x77, 0xbf, 0xea, 0xba, 0xee, 0xef, 0xfb, 
+        0xff, 0x06, 0xff, 0xdf, 0xed, 0xbf, 0xdf, 0xbb, 0xba, 
+        0x5e, 0x55, 0x05, 0xff, 0x77, 0xbf, 0xf5, 0xe2, 0xee, 
+        0xef, 0xeb, 0x55, 0x03, 0xff, 0xdf, 0x75, 0x1f, 0xc0, 
+        0x7b, 0xfb, 0xfe, 0xaa, 0x06, 0xff, 0x77, 0xdf, 0x07, 
+        0xe8, 0xdf, 0xae, 0xaf, 0xa5, 0x06, 0x5f, 0xdf, 0xeb, 
+        0x81, 0xe2, 0xff, 0xf7, 0xfa, 0x92, 0x06, 0xff, 0xf7, 
+        0x7e, 0x20, 0xf5, 0xff, 0xbe, 0x6f, 0xab, 0x06, 0xff, 
+        0x7f, 0x5b, 0x90, 0xe0, 0xff, 0xdb, 0xf6, 0x55, 0x05, 
+        0xff, 0xc7, 0x3f, 0x54, 0xf4, 0xff, 0xff, 0x1f, 0x29, 
+        0x07, 0xdf, 0x3d, 0x09, 0x02, 0xea, 0xff, 0x57, 0xf2, 
+        0xd6, 0x05, 0x7d, 0xff, 0x84, 0xea, 0xff, 0xff, 0x0f, 
+        0xf9, 0x7d, 0x07, 0xd7, 0x8d, 0x47, 0xf5, 0xc3, 0xfe, 
+        0xff, 0xdf, 0xdd, 0x05, 0x7b, 0xcd, 0xc7, 0xfa, 0xe8, 
+        0xfe, 0x7f, 0x9f, 0x75, 0x07, 0xdd, 0xab, 0xa0, 0x1a, 
+        0x00, 0xe1, 0x3b, 0xf0, 0xdf, 0x06, 0x6f, 0x3d, 0x11, 
+        0x0c, 0xab, 0xf6, 0xff, 0xf7, 0xf4, 0x03, 0xfd, 0xb3, 
+        0xa1, 0x86, 0x4b, 0xfe, 0xff, 0x6d, 0xbf, 0x06, 0xb7, 
+        0xba, 0x10, 0xc3, 0x22, 0x6d, 0xff, 0xe7, 0xea, 0x07, 
+        0xed, 0xbb, 0x88, 0xf2, 0x57, 0xf7, 0xff, 0x6b, 0xbe, 
+        0x02, 0x7f, 0xb3, 0xa4, 0x81, 0x00, 0xfc, 0xff, 0x6f, 
+        0xef, 0x07, 0xd5, 0xbb, 0x90, 0x08, 0x72, 0xff, 0xff, 
+        0x6b, 0xfa, 0x06, 0x7f, 0x33, 0x48, 0x09, 0xa8, 0xf7, 
+        0xff, 0x6f, 0xaf, 0x03, 0x2d, 0xb5, 0xa4, 0x08, 0x00, 
+        0xfc, 0xff, 0xef, 0xe6, 0x06, 0x97, 0x3a, 0xc8, 0xac, 
+        0xad, 0x76, 0xff, 0x67, 0x90, 0x07, 0x4d, 0x34, 0xa4, 
+        0x58, 0x77, 0xa9, 0xff, 0xef, 0xaa, 0x06, 0x97, 0xb2, 
+        0xff, 0x5f, 0xdb, 0xd2, 0x59, 0x71, 0x84, 0x03, 0xad, 
+        0xb4, 0xfe, 0x57, 0xa5, 0xec, 0x28, 0x61, 0x55, 0x07, 
+        0x17, 0xba, 0xff, 0xff, 0xff, 0xb6, 0x94, 0x70, 0xa2, 
+        0x05, 0xdd, 0xb3, 0xfd, 0x07, 0x52, 0xff, 0x28, 0x61, 
+        0xab, 0x07, 0xb7, 0xba, 0xff, 0xbf, 0x88, 0xea, 0x94, 
+        0xe8, 0xfe, 0x02, 0xfd, 0x3b, 0xff, 0xff, 0x57, 0x00, 
+        0x9a, 0x70, 0xba, 0x07, 0xb7, 0xb3, 0xff, 0xdf, 0x26, 
+        0x6f, 0x44, 0x6c, 0xef, 0x06, 0xed, 0xba, 0xfe, 0xbf, 
+        0x93, 0x1a, 0x2b, 0x68, 0xb5, 0x03, 0xdf, 0xb5, 0xfb, 
+        0xff, 0x49, 0x1f, 0x45, 0xe4, 0xfe, 0x06, 0xb5, 0x97, 
+        0xff, 0xff, 0x97, 0x86, 0x22, 0x0e, 0xaf, 0x07, 0x7f, 
+        0x23, 0x60, 0x1f, 0x20, 0xc0, 0x12, 0xa8, 0xf6, 0x05, 
+        0xd5, 0x85, 0xf7, 0xff, 0x5b, 0xf0, 0x2a, 0x0b, 0x5d, 
+        0x07, 0x7f, 0x81, 0xff, 0xff, 0x3b, 0x7e, 0x1d, 0x8f, 
+        0xfc, 0x05, 0xd5, 0xa3, 0xd6, 0xff, 0xff, 0xbf, 0x8a, 
+        0x4e, 0x55, 0x07, 0xff, 0x8a, 0x00, 0xff, 0xbf, 0x44, 
+        0x02, 0xa8, 0xfe, 0x05, 0xb5, 0xd5, 0xff, 0xff, 0xbf, 
+        0x12, 0xc1, 0x9f, 0xaa, 0x02, 0xee, 0xbb, 0x6b, 0xff, 
+        0x5f, 0xa4, 0xf0, 0x76, 0x55, 0x05, 0xb5, 0xee, 0xfd, 
+        0xf7, 0x3f, 0x29, 0xa8, 0xdd, 0xad, 0x00, 0xfe, 0x7b, 
+        0xaf, 0xfe, 0xbf, 0x04, 0xfc, 0xfb, 0x75, 0x01, 0xf5, 
+        0xad, 0xfd, 0xdb, 0x3f, 0x01, 0xb7, 0x56, 0xbd, 0x02, 
+        0x7c, 0xff, 0xb7, 0xfe, 0x37, 0x60, 0xed, 0xff, 0x6d, 
+        0x01, 0xee, 0x55, 0xed, 0x57, 0x1f, 0xaa, 0x7f, 0x55, 
+        0x55, 0x01, 0xbb, 0xff, 0x7f, 0xfd, 0xb5, 0xfa, 0xd5, 
+        0xff, 0x55, 0x05, 0x55, 0x54, 0xd5, 0x6f, 0xdf, 0x6f, 
+        0xff, 0xaa, 0x2a, 0x02, 0x57, 0xff, 0x7f, 0xb5, 0x75, 
+        0xb5, 0x55, 0xff, 0x81, 0x07};
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/blank_file?r1=1.1&r2=1.2&diff_format=u
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_variation3.phpt
diff -u /dev/null 
php-src/ext/standard/tests/image/getimagesize_variation3.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_variation3.phpt       Thu Jan 
22 22:59:54 2009
@@ -0,0 +1,70 @@
+--TEST--
+Test getimagesize() function : variation - Passing non image files
+--FILE--
+<?php
+/* Prototype  : array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ */
+
+
+$file_types_array = array (
+    //File containing text string
+       "File with text data" => "test.txt",
+
+       //File containing forcibly corrupted bmp image
+       "File with corrupted BMP data" => "200x100_unknown.unknown",
+
+    //File which doesn't exist
+     "Non-existent file" => "nofile.ext",
+
+    //File having no data
+    "Empty File" => "blank_file.bmp"
+);
+
+echo "*** Testing getimagesize() : variation ***\n";
+
+//loop through each element of the array for filename
+foreach($file_types_array as $key => $filename) {
+      echo "\n-- $key ($filename) --\n";
+      var_dump( getimagesize(dirname(__FILE__)."/$filename" ) );
+      var_dump( getimagesize(dirname(__FILE__)."/$filename", $info) );
+      var_dump( $info );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing getimagesize() : variation ***
+
+-- File with text data (test.txt) --
+bool(false)
+bool(false)
+array(0) {
+}
+
+-- File with corrupted BMP data (200x100_unknown.unknown) --
+bool(false)
+bool(false)
+array(0) {
+}
+
+-- Non-existent file (nofile.ext) --
+
+Warning: getimagesize(%snofile.ext): failed to open stream: No such file or 
directory in %s on line %d
+bool(false)
+
+Warning: getimagesize(%snofile.ext): failed to open stream: No such file or 
directory in %s on line %d
+bool(false)
+array(0) {
+}
+
+-- Empty File (blank_file.bmp) --
+
+Notice: getimagesize(): Read error! in %s on line %d
+bool(false)
+
+Notice: getimagesize(): Read error! in %s on line %d
+bool(false)
+array(0) {
+}
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_error1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_error1.phpt
diff -u /dev/null php-src/ext/standard/tests/image/getimagesize_error1.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_error1.phpt   Thu Jan 22 
22:59:54 2009
@@ -0,0 +1,38 @@
+--TEST--
+Test getimagesize() function : error conditions - wrong number of args
+--FILE--
+<?php
+/* Prototype  : proto array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing getimagesize() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing getimagesize() function with Zero arguments --\n";
+var_dump( getimagesize() );
+
+//Test getimagesize with one more than the expected number of arguments
+echo "\n-- Testing getimagesize() function with more than expected no. of 
arguments --\n";
+$imagefile = 'string_val';
+$info = array(1, 2);
+$extra_arg = 10;
+var_dump( getimagesize($imagefile, $info, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getimagesize() : error conditions ***
+
+-- Testing getimagesize() function with Zero arguments --
+
+Warning: getimagesize() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing getimagesize() function with more than expected no. of arguments --
+
+Warning: getimagesize() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/image/getimagesize_variation1.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_variation1.phpt       Thu Jan 
22 22:59:54 2009
@@ -0,0 +1,192 @@
+--TEST--
+Test getimagesize() function : usage variations  - unexpected type for arg 1
+--FILE--
+<?php
+/* Prototype  : proto array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ * Alias to functions: 
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing getimagesize() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$info = array(1, 2);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+      // int data
+      "0" => 0,
+      "1" => 1,
+      "12345" => 12345,
+      "-2345" => -2345,
+
+      // float data
+      "10.5" => 10.5,
+      "-10.5" => -10.5,
+      "10.1234567e5" => 10.1234567e10,
+      "10.7654321e-5" => 10.7654321E-5,
+      .5,
+
+      // array data
+      "array()" => array(),
+      "array(0)" => array(0),
+      "array(1)" => array(1),
+      "array(1, 2)" => array(1, 2),
+      "array('color' => 'red', 'item' => 'pen')" => array('color' => 'red', 
'item' => 'pen'),
+
+      // null data
+      "NULL" => NULL,
+      "null" => null,
+
+      // boolean data
+      "true" => true,
+      "false" => false,
+      "TRUE" => TRUE,
+      "FALSE" => FALSE,
+
+      // empty data
+      "\"\"" => "",
+      "''" => '',
+
+      // object data
+      "new stdclass()" => new stdclass(),
+
+      // undefined data
+      "undefined_var" => $undefined_var,
+
+      // unset data
+      "unset_var" => $unset_var,
+);
+
+// loop through each element of the array for imagefile
+
+foreach($values as $key => $value) {
+      echo "\n-- Arg value: $key --\n";
+      var_dump( getimagesize($value, $info) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getimagesize() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(%d)
+Error: 8 - Undefined variable: unset_var, %s(%d)
+
+-- Arg value: 0 --
+Error: 2 - getimagesize(0): failed to open stream: No such file or directory, 
%s
+bool(false)
+
+-- Arg value: 1 --
+Error: 2 - getimagesize(1): failed to open stream: No such file or directory, 
%s
+bool(false)
+
+-- Arg value: 12345 --
+Error: 2 - getimagesize(12345): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: -2345 --
+Error: 2 - getimagesize(-2345): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: 10.5 --
+Error: 2 - getimagesize(10.5): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: -10.5 --
+Error: 2 - getimagesize(-10.5): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: 10.1234567e5 --
+Error: 2 - getimagesize(101234567000): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: 10.7654321e-5 --
+Error: 2 - getimagesize(0.000107654321): failed to open stream: No such file 
or directory, %s
+bool(false)
+
+-- Arg value: 12346 --
+Error: 2 - getimagesize(0.5): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: array() --
+Error: 8 - Array to string conversion, %s
+Error: 2 - getimagesize(Array): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: array(0) --
+Error: 8 - Array to string conversion, %s
+Error: 2 - getimagesize(Array): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: array(1) --
+Error: 8 - Array to string conversion, %s
+Error: 2 - getimagesize(Array): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: array(1, 2) --
+Error: 8 - Array to string conversion, %s
+Error: 2 - getimagesize(Array): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: array('color' => 'red', 'item' => 'pen') --
+Error: 8 - Array to string conversion, %s
+Error: 2 - getimagesize(Array): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: NULL --
+Error: 2 - getimagesize(): Filename cannot be empty, %s
+bool(false)
+
+-- Arg value: null --
+Error: 2 - getimagesize(): Filename cannot be empty, %s
+bool(false)
+
+-- Arg value: true --
+Error: 2 - getimagesize(1): failed to open stream: No such file or directory, 
%s
+bool(false)
+
+-- Arg value: false --
+Error: 2 - getimagesize(): Filename cannot be empty, %s
+bool(false)
+
+-- Arg value: TRUE --
+Error: 2 - getimagesize(1): failed to open stream: No such file or directory, 
%s
+bool(false)
+
+-- Arg value: FALSE --
+Error: 2 - getimagesize(): Filename cannot be empty, %s
+bool(false)
+
+-- Arg value: "" --
+Error: 2 - getimagesize(): Filename cannot be empty, %s
+bool(false)
+
+-- Arg value: '' --
+Error: 2 - getimagesize(): Filename cannot be empty, %s
+bool(false)
+
+-- Arg value: new stdclass() --
+Error: 4096 - Object of class stdClass could not be converted to binary 
string, %s
+Error: 8 - Object of class stdClass to string conversion, %s
+Error: 2 - getimagesize(Object): failed to open stream: No such file or 
directory, %s
+bool(false)
+
+-- Arg value: undefined_var --
+Error: 2 - getimagesize(): Filename cannot be empty, %s
+bool(false)
+
+-- Arg value: unset_var --
+Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
+bool(false)
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_jpgapp.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_jpgapp.phpt
diff -u /dev/null php-src/ext/standard/tests/image/getimagesize_jpgapp.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_jpgapp.phpt   Thu Jan 22 
22:59:54 2009
@@ -0,0 +1,37 @@
+--TEST--
+Test getimagesize() function : basic functionality - load APP info from jpeg.
+--SKIPIF--
+<?php
+       if (!defined("IMAGETYPE_JPEG")) {
+               die("skip jpeg format is not available");
+       }
+?>
+--FILE--
+<?php
+/* Prototype  : proto array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ * Alias to functions: 
+ */
+
+/*
+ * Load APP info from jpeg
+ */
+
+$arr['this'] = "will";
+$arr['all'] = "be destroyed!";
+$arr['APP1'] = "and this too";
+
+getimagesize( dirname(__FILE__)."/testAPP.jpg", $arr);
+
+foreach ($arr as $key => $value) {
+       echo "$key - length: ". strlen($value) ."; md5: " . md5((binary)$value) 
.  "\n" ;
+}
+
+?>
+===DONE===
+--EXPECTF--
+APP1 - length: 1717; md5: 02cbf4ba6640c131422483138c968516
+APP2 - length: 7275; md5: f5036ccca2031e8bf932bcbd4aca4355
+APP13 - length: 42; md5: 2202998bd05e78bcb419f08c070d6f61
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/getimagesize_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/image/getimagesize_variation4.phpt
diff -u /dev/null 
php-src/ext/standard/tests/image/getimagesize_variation4.phpt:1.2
--- /dev/null   Thu Jan 22 22:59:54 2009
+++ php-src/ext/standard/tests/image/getimagesize_variation4.phpt       Thu Jan 
22 22:59:54 2009
@@ -0,0 +1,38 @@
+--TEST--
+Test getimagesize() function : variation - For shockwave-flash format
+--SKIPIF--
+<?php
+       if (!defined("IMAGETYPE_SWC") || !extension_loaded('zlib')) {
+               die("skip zlib extension is not available");
+       }
+?>
+--FILE--
+<?php
+/* Prototype  : array getimagesize(string imagefile [, array info])
+ * Description: Get the size of an image as 4-element array 
+ * Source code: ext/standard/image.c
+ */
+
+echo "*** Testing getimagesize() : variation ***\n";
+
+var_dump( getimagesize(dirname(__FILE__)."/test13pix.swf", $info) );
+var_dump( $info );
+?>
+===DONE===
+--EXPECTF--
+*** Testing getimagesize() : variation ***
+array(5) {
+  [0]=>
+  int(550)
+  [1]=>
+  int(400)
+  [2]=>
+  int(13)
+  [3]=>
+  unicode(24) "width="550" height="400""
+  [u"mime"]=>
+  unicode(29) "application/x-shockwave-flash"
+}
+array(0) {
+}
+===DONE===
\ No newline at end of file

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

Reply via email to