xref: /PHP-8.0/ext/zlib/tests/gzclose_basic.phpt (revision c5401854)
1--TEST--
2Test function gzclose() by calling it with its expected arguments
3--SKIPIF--
4<?php
5if (!extension_loaded("zlib")) {
6    print "skip - ZLIB extension not loaded";
7}
8?>
9--FILE--
10<?php
11// note that gzclose is an alias to fclose. parameter checking tests will be
12// the same as fclose
13
14$f = __DIR__."/004.txt.gz";
15$h = gzopen($f, 'r');
16gzread($h, 20);
17var_dump(gzclose($h));
18
19//should fail.
20try {
21    gzread($h, 20);
22} catch (TypeError $e) {
23    echo $e->getMessage(), "\n";
24}
25
26$h = gzopen($f, 'r');
27gzread($h, 20);
28var_dump(fclose($h));
29
30//should fail.
31try {
32    gzread($h, 20);
33} catch (TypeError $e) {
34    echo $e->getMessage(), "\n";
35}
36
37
38?>
39--EXPECT--
40bool(true)
41gzread(): supplied resource is not a valid stream resource
42bool(true)
43gzread(): supplied resource is not a valid stream resource
44