xref: /PHP-5.6/ext/zip/tests/oo_stream.phpt (revision 8ad0c6d5)
1--TEST--
2getStream
3--SKIPIF--
4<?php
5/* $Id$ */
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
19var_dump($fp);
20if(!$fp) exit("\n");
21$contents = '';
22while (!feof($fp)) {
23	$contents .= fread($fp, 255);
24}
25
26fclose($fp);
27$zip->close();
28var_dump($contents);
29
30
31$fp = fopen('zip://' . dirname(__FILE__) . '/test_with_comment.zip#foo', 'rb');
32if (!$fp) {
33  exit("cannot open\n");
34}
35$contents = '';
36while (!feof($fp)) {
37  $contents .= fread($fp, 2);
38}
39var_dump($contents);
40fclose($fp);
41
42?>
43--EXPECTF--
44resource(%d) of type (stream)
45string(5) "foo
46
47"
48string(5) "foo
49
50"
51