]> granicus.if.org Git - php/commitdiff
- Add constants and new test (test from testfest.php.net)
authorMarcus Boerger <helly@php.net>
Sat, 24 May 2008 11:53:35 +0000 (11:53 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 24 May 2008 11:53:35 +0000 (11:53 +0000)
ext/standard/image.c
ext/standard/php_image.h
ext/standard/tests/image/image_type_to_mime_type_variation3.phpt [new file with mode: 0755]

index 8d8d0c66c35ae93afbec266428b1e939994357a2..a83b9669c28533f5db74c89e53faa739e2c38219 100644 (file)
@@ -89,6 +89,8 @@ PHP_MINIT_FUNCTION(imagetypes)
        REGISTER_LONG_CONSTANT("IMAGETYPE_JPEG2000",IMAGE_FILETYPE_JPC,     CONST_CS | CONST_PERSISTENT); /* keep alias */
        REGISTER_LONG_CONSTANT("IMAGETYPE_XBM",     IMAGE_FILETYPE_XBM,     CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IMAGETYPE_ICO",     IMAGE_FILETYPE_ICO,     CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IMAGETYPE_UNKNOWN", IMAGE_FILETYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IMAGETYPE_COUNT",   IMAGE_FILETYPE_COUNT,   CONST_CS | CONST_PERSISTENT);
        return SUCCESS;
 }
 /* }}} */
index 4b2f8034d09d72d65067066f7c9aec3b4853bce6..18b2f3dfcbd02c255d03634d5c27b6ad3ad71df5 100644 (file)
@@ -50,8 +50,9 @@ typedef enum
   IMAGE_FILETYPE_WBMP,
   /* IMAGE_FILETYPE_JPEG2000 is a userland alias for IMAGE_FILETYPE_JPC */
   IMAGE_FILETYPE_XBM,
-  IMAGE_FILETYPE_ICO
+  IMAGE_FILETYPE_ICO,
 /* WHEN EXTENDING: PLEASE ALSO REGISTER IN image.c:PHP_MINIT_FUNCTION(imagetypes) */
+  IMAGE_FILETYPE_COUNT
 } image_filetype;
 /* }}} */
 
diff --git a/ext/standard/tests/image/image_type_to_mime_type_variation3.phpt b/ext/standard/tests/image/image_type_to_mime_type_variation3.phpt
new file mode 100755 (executable)
index 0000000..e4f935d
--- /dev/null
@@ -0,0 +1,139 @@
+--TEST--
+image_type_to_mime_type() (passinf equivalent integer values)
+--CREDITS--
+Sanjay Mantoor <sanjay.mantoor@gmail.com>
+--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";
+
+for($imagetype = 0; $imagetype <= IMAGETYPE_COUNT; ++$imagetype) {
+  echo "\n-- Iteration $imagetype --\n";
+  var_dump(image_type_to_mime_type($imagetype));
+}
+?>
+===DONE===
+--EXPECTREGEX--
+\*\*\* Testing image_type_to_mime_type\(\) : usage variations \*\*\*
+
+-- Iteration 0 --
+string\(24\) "application\/octet-stream"
+
+-- 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"
+
+-- Iteration 18 --
+string\(24\) "application\/octet-stream"
+===DONE===
+--UEXPECTREGEX--
+\*\*\* Testing image_type_to_mime_type\(\) : usage variations \*\*\*
+
+-- Iteration 0 --
+unicode\(24\) "application\/octet-stream"
+
+-- Iteration 1 --
+unicode\(9\) "image\/gif"
+
+-- Iteration 2 --
+unicode\(10\) "image\/jpeg"
+
+-- Iteration 3 --
+unicode\(9\) "image\/png"
+
+-- Iteration 4 --
+unicode\(29\) "application\/x-shockwave-flash"
+
+-- Iteration 5 --
+unicode\(9\) "image\/psd"
+
+-- Iteration 6 --
+unicode\(9\) "image\/bmp"
+
+-- Iteration 7 --
+unicode\(10\) "image\/tiff"
+
+-- Iteration 8 --
+unicode\(10\) "image\/tiff"
+
+-- Iteration 9 --
+unicode\(24\) "application\/octet-stream"
+
+-- Iteration 10 --
+unicode\(9\) "image\/jp2"
+
+-- Iteration 11 --
+unicode\(24\) "application\/octet-stream"
+
+-- Iteration 12 --
+unicode\(24\) "application\/octet-stream"
+
+-- Iteration 13 --
+unicode\(2[49]\) "application\/(x-shockwave-flash|octet-stream)"
+
+-- Iteration 14 --
+unicode\(9\) "image\/iff"
+
+-- Iteration 15 --
+unicode\(18\) "image\/vnd.wap.wbmp"
+
+-- Iteration 16 --
+unicode\(9\) "image\/xbm"
+
+-- Iteration 17 --
+unicode\(24\) "image\/vnd.microsoft.icon"
+
+-- Iteration 18 --
+unicode\(24\) "application\/octet-stream"
+===DONE===