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