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