summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/zlib/tests/gzopen_variation8.phpt42
-rw-r--r--ext/zlib/tests/gzopen_variation9.phpt55
-rw-r--r--ext/zlib/tests/gzseek_variation6.phpt39
-rw-r--r--ext/zlib/tests/gzseek_variation7.phpt47
-rw-r--r--ext/zlib/tests/zlib_scheme_copy_basic.phpt37
-rw-r--r--ext/zlib/tests/zlib_scheme_copy_variation1.phpt38
-rw-r--r--ext/zlib/tests/zlib_scheme_copy_variation2.phpt53
-rw-r--r--ext/zlib/tests/zlib_scheme_dir_basic.phpt26
-rw-r--r--ext/zlib/tests/zlib_scheme_file_basic.phpt38
-rw-r--r--ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt24
-rw-r--r--ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt31
-rw-r--r--ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt23
-rw-r--r--ext/zlib/tests/zlib_scheme_fopen_basic.phpt25
-rw-r--r--ext/zlib/tests/zlib_scheme_rename_basic.phpt21
-rw-r--r--ext/zlib/tests/zlib_scheme_stat_basic.phpt22
-rw-r--r--ext/zlib/tests/zlib_scheme_stat_basic2.phpt46
-rw-r--r--ext/zlib/tests/zlib_scheme_unlink_basic.phpt21
17 files changed, 588 insertions, 0 deletions
diff --git a/ext/zlib/tests/gzopen_variation8.phpt b/ext/zlib/tests/gzopen_variation8.phpt
new file mode 100644
index 0000000..bb01262
--- /dev/null
+++ b/ext/zlib/tests/gzopen_variation8.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Test gzopen() function : variation: opening a plain file
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
+ * Description: Open a .gz-file and return a .gz-file pointer
+ * Source code: ext/zlib/zlib.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gzopen() : variation ***\n";
+
+$data = <<<EOT
+Here is some plain
+text to be read
+and displayed.
+EOT;
+
+$file = "gzopen_variation8.tmp";
+$h = fopen($file, 'w');
+fwrite($h, $data);
+fclose($h);
+
+$h = gzopen($file, 'r');
+gzpassthru($h);
+gzclose($h);
+echo "\n";
+unlink($file);
+?>
+===DONE===
+--EXPECT--
+*** Testing gzopen() : variation ***
+Here is some plain
+text to be read
+and displayed.
+===DONE===
diff --git a/ext/zlib/tests/gzopen_variation9.phpt b/ext/zlib/tests/gzopen_variation9.phpt
new file mode 100644
index 0000000..7a44b6e
--- /dev/null
+++ b/ext/zlib/tests/gzopen_variation9.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test gzopen() function : variation: try opening with possibly invalid modes
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
+ * Description: Open a .gz-file and return a .gz-file pointer
+ * Source code: ext/zlib/zlib.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gzopen() : variation ***\n";
+
+$modes = array('r+', 'rf', 'w+' , 'e');
+
+$file = dirname(__FILE__)."/004.txt.gz";
+
+foreach ($modes as $mode) {
+ echo "mode=$mode\n";
+ $h = gzopen($file, $mode);
+ echo "gzopen=";
+ var_dump($h);
+ if ($h !== false) {
+ gzclose($h);
+ }
+ echo "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+*** Testing gzopen() : variation ***
+mode=r+
+
+Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
+gzopen=bool(false)
+
+mode=rf
+gzopen=resource(%d) of type (stream)
+
+mode=w+
+
+Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
+gzopen=bool(false)
+
+mode=e
+
+Warning: gzopen(%s/004.txt.gz): failed to open stream: %s in %s on line %d
+gzopen=bool(false)
+
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/gzseek_variation6.phpt b/ext/zlib/tests/gzseek_variation6.phpt
new file mode 100644
index 0000000..0c46309
--- /dev/null
+++ b/ext/zlib/tests/gzseek_variation6.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Test function gzseek() by calling it with SEEK_END when reading
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$f = dirname(__FILE__)."/004.txt.gz";
+$h = gzopen($f, 'r');
+// move 40 bytes
+echo "move 40 bytes\n";
+gzread($h, 40);
+echo "tell=";
+var_dump(gztell($h));
+echo "move to the end\n";
+var_dump(gzseek( $h, 0, SEEK_END ) );
+echo "tell=";
+var_dump(gztell($h));
+echo "eof=";
+var_dump(gzeof($h));
+//read the next 10
+var_dump(gzread($h, 10));
+gzclose($h);
+?>
+===DONE===
+--EXPECTF--
+move 40 bytes
+tell=int(40)
+move to the end
+
+Warning: gzseek(): SEEK_END is not supported in %s on line %d
+int(-1)
+tell=int(40)
+eof=bool(false)
+string(10) "iny flying"
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/gzseek_variation7.phpt b/ext/zlib/tests/gzseek_variation7.phpt
new file mode 100644
index 0000000..aab0834
--- /dev/null
+++ b/ext/zlib/tests/gzseek_variation7.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test function gzseek() by calling it with SEEK_END when writing
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$f = "temp3.txt.gz";
+$h = gzopen($f, 'w');
+$str1 = "This is the first line.";
+$str2 = "This is the second line.";
+gzwrite($h, $str1);
+echo "tell=";
+var_dump(gztell($h));
+
+//seek to the end which is not sensible of course.
+echo "move to the end of the file\n";
+var_dump(gzseek($h, 0, SEEK_END));
+echo "tell=";
+var_dump(gztell($h));
+gzwrite($h, $str2);
+echo "tell=";
+var_dump(gztell($h));
+gzclose($h);
+echo "\nreading the output file\n";
+$h = gzopen($f, 'r');
+gzpassthru($h);
+gzclose($h);
+echo "\n";
+unlink($f);
+?>
+===DONE===
+--EXPECTF--
+tell=int(23)
+move to the end of the file
+
+Warning: gzseek(): SEEK_END is not supported in %s on line %d
+int(-1)
+tell=int(23)
+tell=int(47)
+
+reading the output file
+This is the first line.This is the second line.
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_copy_basic.phpt b/ext/zlib/tests/zlib_scheme_copy_basic.phpt
new file mode 100644
index 0000000..028c029
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_copy_basic.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test compress.zlib:// scheme with the copy function: compressed to compressed
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$outputFileName = __FILE__.'.tmp';
+
+$srcFile = "compress.zlib://$inputFileName";
+$destFile = "compress.zlib://$outputFileName";
+copy($srcFile, $destFile);
+
+$h = gzopen($inputFileName, 'r');
+$org_data = gzread($h, 4096);
+gzclose($h);
+
+$h = gzopen($outputFileName, 'r');
+$copied_data = gzread($h, 4096);
+gzclose($h);
+
+if ($org_data == $copied_data) {
+ echo "OK: Copy identical\n";
+}
+else {
+ echo "FAILED: Copy not identical";
+}
+unlink($outputFileName);
+?>
+===DONE===
+--EXPECT--
+OK: Copy identical
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_copy_variation1.phpt b/ext/zlib/tests/zlib_scheme_copy_variation1.phpt
new file mode 100644
index 0000000..3c997ef
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_copy_variation1.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test compress.zlib:// scheme with the copy function: compressed to uncompressed
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$outputFileName = __FILE__.'.tmp';
+
+$srcFile = "compress.zlib://$inputFileName";
+$destFile = $outputFileName;
+copy($srcFile, $destFile);
+
+$h = gzopen($inputFileName, 'r');
+$org_data = gzread($h, 4096);
+gzclose($h);
+
+// can only read uncompressed data
+$h = fopen($outputFileName, 'r');
+$copied_data = fread($h, 4096);
+gzclose($h);
+
+if ($org_data == $copied_data) {
+ echo "OK: Copy identical\n";
+}
+else {
+ echo "FAILED: Copy not identical";
+}
+unlink($outputFileName);
+?>
+===DONE===
+--EXPECT--
+OK: Copy identical
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_copy_variation2.phpt b/ext/zlib/tests/zlib_scheme_copy_variation2.phpt
new file mode 100644
index 0000000..0b56ec4
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_copy_variation2.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test compress.zlib:// scheme with the copy function: uncompressed to compressed
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$org_data = <<<EOT
+uncompressed contents of 004.txt.gz is:
+When you're taught through feelings
+Destiny flying high above
+all I know is that you can realize it
+Destiny who cares
+as it turns around
+and I know that it descends down on me
+EOT;
+
+$inputFileName = __FILE__.'.org';
+$outputFileName = __FILE__.'.tmp';
+
+file_put_contents($inputFileName, $org_data);
+
+$srcFile = $inputFileName;
+$destFile = "compress.zlib://$outputFileName";
+copy($srcFile, $destFile);
+
+$h = gzopen($outputFileName, 'r');
+$copied_data = gzread($h, 4096);
+gzclose($h);
+
+//gzopen can read compressed and uncompressed so we
+//also need to look for the magic number (x1f x8b) to prove it
+//was compressed.
+$h = fopen($outputFileName, 'r');
+$magic = fread($h, 2);
+fclose($h);
+
+if ($org_data == $copied_data && bin2hex($magic) === '1f8b') {
+ echo "OK: Copy identical\n";
+}
+else {
+ echo "FAILED: Copy not identical\n";
+}
+unlink($inputFileName);
+unlink($outputFileName);
+?>
+===DONE===
+--EXPECT--
+OK: Copy identical
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_dir_basic.phpt b/ext/zlib/tests/zlib_scheme_dir_basic.phpt
new file mode 100644
index 0000000..02fe4fd
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_dir_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Test compress.zlib:// scheme with the directory functions
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/dir.gz";
+$srcFile = "compress.zlib://$inputFileName";
+var_dump(mkdir($srcFile));
+var_dump(is_dir($srcFile));
+var_dump(opendir($srcFile));
+var_dump(rmdir($srcFile));
+?>
+===DONE===
+--EXPECTF--
+bool(false)
+bool(false)
+
+Warning: opendir(compress.zlib://%s/dir.gz): failed to open dir: not implemented in %s on line %d
+bool(false)
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_file_basic.phpt b/ext/zlib/tests/zlib_scheme_file_basic.phpt
new file mode 100644
index 0000000..b8b60e4
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_file_basic.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test compress.zlib:// scheme with the file
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+$contents = file($srcFile);
+var_dump($contents);
+?>
+===DONE===
+--EXPECT--
+array(6) {
+ [0]=>
+ string(36) "When you're taught through feelings
+"
+ [1]=>
+ string(26) "Destiny flying high above
+"
+ [2]=>
+ string(38) "all I know is that you can realize it
+"
+ [3]=>
+ string(18) "Destiny who cares
+"
+ [4]=>
+ string(19) "as it turns around
+"
+ [5]=>
+ string(39) "and I know that it descends down on me
+"
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt b/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt
new file mode 100644
index 0000000..c679c46
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test compress.zlib:// scheme with the file_get_contents
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+$contents = file_get_contents($srcFile);
+echo $contents;
+?>
+===DONE===
+--EXPECT--
+When you're taught through feelings
+Destiny flying high above
+all I know is that you can realize it
+Destiny who cares
+as it turns around
+and I know that it descends down on me
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt b/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt
new file mode 100644
index 0000000..8ea41df
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test compress.zlib:// scheme with the file_get_contents
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$outputFileName = __FILE__.'tmp';
+$outFile = "compress.zlib://$outputFileName";
+$data = <<<EOT
+Here is some plain
+text to be read
+and displayed.
+EOT;
+
+file_put_contents($outFile, $data);
+$h = gzopen($outputFileName, 'r');
+gzpassthru($h);
+gzclose($h);
+echo "\n";
+unlink($outputFileName);
+?>
+===DONE===
+--EXPECT--
+Here is some plain
+text to be read
+and displayed.
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt b/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt
new file mode 100644
index 0000000..ef44292
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test compress.zlib:// scheme with the file_get_contents
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+readfile($srcFile);
+?>
+===DONE===
+--EXPECT--
+When you're taught through feelings
+Destiny flying high above
+all I know is that you can realize it
+Destiny who cares
+as it turns around
+and I know that it descends down on me
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_fopen_basic.phpt b/ext/zlib/tests/zlib_scheme_fopen_basic.phpt
new file mode 100644
index 0000000..d6d4514
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_fopen_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test compress.zlib:// scheme with the fopen
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+$h = fopen($srcFile, 'r');
+fpassthru($h);
+fclose($h);
+?>
+===DONE===
+--EXPECT--
+When you're taught through feelings
+Destiny flying high above
+all I know is that you can realize it
+Destiny who cares
+as it turns around
+and I know that it descends down on me
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_rename_basic.phpt b/ext/zlib/tests/zlib_scheme_rename_basic.phpt
new file mode 100644
index 0000000..9de55aa
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_rename_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test compress.zlib:// scheme with the unlink function
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+rename($srcFile, 'something.tmp');
+var_dump(file_exists($inputFileName));
+?>
+===DONE===
+--EXPECTF--
+
+Warning: rename(): ZLIB wrapper does not support renaming in %s on line %d
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_stat_basic.phpt b/ext/zlib/tests/zlib_scheme_stat_basic.phpt
new file mode 100644
index 0000000..10cd9a4
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_stat_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test compress.zlib:// scheme with the unlink function
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+stat($srcFile);
+lstat($srcFile);
+?>
+===DONE===
+--EXPECTF--
+
+Warning: stat(): stat failed for compress.zlib://%s/004.txt.gz in %s on line %d
+
+Warning: lstat(): Lstat failed for compress.zlib://%s/004.txt.gz in %s on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_stat_basic2.phpt b/ext/zlib/tests/zlib_scheme_stat_basic2.phpt
new file mode 100644
index 0000000..e78bcd7
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_stat_basic2.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test compress.zlib:// scheme with the unlink function
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+echo "file_exists=";
+var_dump(file_exists($srcFile));
+echo "is_file=";
+var_dump(is_file($srcFile));
+echo "is_dir=";
+var_dump(is_dir($srcFile));
+echo "is_readable=";
+var_dump(is_readable($srcFile));
+echo "\n";
+echo "filesize=";
+var_dump(filesize($srcFile));
+echo "filetype=";
+var_dump(filetype($srcFile));
+echo "fileatime=";
+var_dump(fileatime($srcFile));
+
+?>
+===DONE===
+--EXPECTF--
+file_exists=bool(false)
+is_file=bool(false)
+is_dir=bool(false)
+is_readable=bool(false)
+
+filesize=
+Warning: filesize(): stat failed for compress.zlib://%s004.txt.gz in %s on line %d
+bool(false)
+filetype=
+Warning: filetype(): Lstat failed for compress.zlib://%s004.txt.gz in %s on line %d
+bool(false)
+fileatime=
+Warning: fileatime(): stat failed for compress.zlib://%s004.txt.gz in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/zlib/tests/zlib_scheme_unlink_basic.phpt b/ext/zlib/tests/zlib_scheme_unlink_basic.phpt
new file mode 100644
index 0000000..b05e45b
--- /dev/null
+++ b/ext/zlib/tests/zlib_scheme_unlink_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test compress.zlib:// scheme with the unlink function
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+}
+?>
+--FILE--
+<?php
+$inputFileName = dirname(__FILE__)."/004.txt.gz";
+$srcFile = "compress.zlib://$inputFileName";
+unlink($srcFile);
+var_dump(file_exists($inputFileName));
+?>
+===DONE===
+--EXPECTF--
+
+Warning: unlink(): ZLIB does not allow unlinking in %s on line %d
+bool(true)
+===DONE=== \ No newline at end of file