xref: /PHP-5.5/ext/zlib/tests/gzopen_basic2.phpt (revision 9c1e1bbc)
1--TEST--
2Test gzopen() function : basic functionality for writing
3--SKIPIF--
4<?php
5if (!extension_loaded("zlib")) {
6	print "skip - ZLIB extension not loaded";
7}
8?>
9--FILE--
10<?php
11/* Prototype  : resource gzopen(string filename, string mode [, int use_include_path])
12 * Description: Open a .gz-file and return a .gz-file pointer
13 * Source code: ext/zlib/zlib.c
14 * Alias to functions:
15 */
16
17echo "*** Testing gzopen() : basic functionality ***\n";
18
19
20// Initialise all required variables
21$filename = "gzopen_basic2.txt.gz";
22$modes = array('w', 'w+');
23$data = "This was the information that was written";
24
25foreach($modes as $mode) {
26   echo "testing mode -- $mode --\n";
27   $h = gzopen($filename, $mode);
28   if ($h !== false) {
29      gzwrite($h, $data);
30      gzclose($h);
31      $h = gzopen($filename, 'r');
32      gzpassthru($h);
33      gzclose($h);
34      echo "\n";
35      unlink($filename);
36   }
37   else {
38      var_dump($h);
39   }
40}
41
42?>
43===DONE===
44--EXPECTF--
45*** Testing gzopen() : basic functionality ***
46testing mode -- w --
47This was the information that was written
48testing mode -- w+ --
49
50Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
51bool(false)
52===DONE===
53