xref: /PHP-8.0/ext/zip/tests/stream_meta_data.phpt (revision f8d79582)
1--TEST--
2stream_get_meta_data() on zip stream
3--SKIPIF--
4<?php
5if(!extension_loaded('zip')) die('skip');
6?>
7--FILE--
8<?php
9$dirname = __DIR__ . '/';
10$file = $dirname . 'test_with_comment.zip';
11include $dirname . 'utils.inc';
12$zip = new ZipArchive;
13if (!$zip->open($file)) {
14    exit('failed');
15}
16$fp = $zip->getStream('foo');
17
18if(!$fp) exit("\n");
19
20var_dump(stream_get_meta_data($fp));
21
22fclose($fp);
23$zip->close();
24
25
26$fp = fopen('zip://' . __DIR__ . '/test_with_comment.zip#foo', 'rb');
27if (!$fp) {
28  exit("cannot open\n");
29}
30
31var_dump(stream_get_meta_data($fp));
32fclose($fp);
33
34?>
35--EXPECTF--
36array(8) {
37  ["timed_out"]=>
38  bool(false)
39  ["blocked"]=>
40  bool(true)
41  ["eof"]=>
42  bool(false)
43  ["stream_type"]=>
44  string(3) "zip"
45  ["mode"]=>
46  string(2) "rb"
47  ["unread_bytes"]=>
48  int(0)
49  ["seekable"]=>
50  bool(false)
51  ["uri"]=>
52  string(3) "foo"
53}
54array(9) {
55  ["timed_out"]=>
56  bool(false)
57  ["blocked"]=>
58  bool(true)
59  ["eof"]=>
60  bool(false)
61  ["wrapper_type"]=>
62  string(11) "zip wrapper"
63  ["stream_type"]=>
64  string(3) "zip"
65  ["mode"]=>
66  string(2) "rb"
67  ["unread_bytes"]=>
68  int(0)
69  ["seekable"]=>
70  bool(false)
71  ["uri"]=>
72  string(%d) "zip://%stest_with_comment.zip#foo"
73}
74