summaryrefslogtreecommitdiff
path: root/ext/fileinfo/tests/finfo_buffer_basic.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/fileinfo/tests/finfo_buffer_basic.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/fileinfo/tests/finfo_buffer_basic.phpt')
-rw-r--r--ext/fileinfo/tests/finfo_buffer_basic.phpt55
1 files changed, 55 insertions, 0 deletions
diff --git a/ext/fileinfo/tests/finfo_buffer_basic.phpt b/ext/fileinfo/tests/finfo_buffer_basic.phpt
new file mode 100644
index 0000000..0c3c641
--- /dev/null
+++ b/ext/fileinfo/tests/finfo_buffer_basic.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test finfo_buffer() function : basic functionality
+--SKIPIF--
+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--FILE--
+<?php
+/* Prototype : string finfo_buffer(resource finfo, char *string [, int options [, resource context]])
+ * Description: Return infromation about a string buffer.
+ * Source code: ext/fileinfo/fileinfo.c
+ * Alias to functions:
+ */
+
+$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic';
+
+$options = array(
+ FILEINFO_NONE,
+ FILEINFO_MIME,
+);
+
+$buffers = array(
+ "Regular string here",
+ "\177ELF",
+ "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003",
+ "\x55\x7A\x6E\x61",
+ "id=ImageMagick",
+ "RIFFüîò^BAVI LISTv",
+);
+
+echo "*** Testing finfo_buffer() : basic functionality ***\n";
+
+foreach( $options as $option ) {
+ $finfo = finfo_open( $option, $magicFile );
+ foreach( $buffers as $string ) {
+ var_dump( finfo_buffer( $finfo, $string, $option ) );
+ }
+ finfo_close( $finfo );
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing finfo_buffer() : basic functionality ***
+string(36) "ASCII text, with no line terminators"
+string(3) "ELF"
+string(22) "old ACE/gr binary file"
+string(12) "xo65 object,"
+string(15) "MIFF image data"
+string(25) "RIFF (little-endian) data"
+string(28) "text/plain; charset=us-ascii"
+string(26) "text/plain; charset=ebcdic"
+string(40) "application/octet-stream; charset=binary"
+string(28) "text/plain; charset=us-ascii"
+string(28) "text/plain; charset=us-ascii"
+string(25) "text/plain; charset=utf-8"
+===DONE===