xref: /PHP-5.3/ext/phar/tests/022.phpt (revision 228c2886)
1--TEST--
2Phar: stream stat
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7detect_unicode=0
8--FILE--
9<?php
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
11$pname = 'phar://' . $fname;
12$file = "<?php
13Phar::mapPhar('hio');
14__HALT_COMPILER(); ?>";
15
16$files = array();
17$files['a'] = 'abcdefg';
18
19include 'files/phar_test.inc';
20
21include $fname;
22
23$fp = fopen('phar://hio/a', 'r');
24var_dump(ftell($fp));
25echo 'fseek($fp, 1)';var_dump(fseek($fp, 1));
26var_dump(ftell($fp));
27echo 'fseek($fp, 1, SEEK_CUR)';var_dump(fseek($fp, 1, SEEK_CUR));
28var_dump(ftell($fp));
29echo 'fseek($fp, -1, SEEK_CUR)';var_dump(fseek($fp, -1, SEEK_CUR));
30var_dump(ftell($fp));
31echo 'fseek($fp, -1, SEEK_END)';var_dump(fseek($fp, -1, SEEK_END));
32var_dump(ftell($fp));
33echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
34var_dump(ftell($fp));
35echo 'fseek($fp, -7, SEEK_END)';var_dump(fseek($fp, -7, SEEK_END));
36var_dump(ftell($fp));
37echo 'fseek($fp, 0, SEEK_END)';var_dump(fseek($fp, 0, SEEK_END));
38var_dump(ftell($fp));
39echo 'fseek($fp, 1, SEEK_END)';var_dump(fseek($fp, 1, SEEK_END));
40var_dump(ftell($fp));
41echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
42var_dump(ftell($fp));
43echo 'fseek($fp, 6)';var_dump(fseek($fp, 6));
44var_dump(ftell($fp));
45echo 'fseek($fp, 8)';var_dump(fseek($fp, 8));
46var_dump(ftell($fp));
47echo 'fseek($fp, -1)';var_dump(fseek($fp, -1));
48var_dump(ftell($fp));
49echo "next\n";
50fseek($fp, 4);
51var_dump(ftell($fp));
52echo 'fseek($fp, -5, SEEK_CUR)';var_dump(fseek($fp, -5, SEEK_CUR));
53var_dump(ftell($fp));
54fseek($fp, 4);
55var_dump(ftell($fp));
56echo 'fseek($fp, 5, SEEK_CUR)';var_dump(fseek($fp, 5, SEEK_CUR));
57var_dump(ftell($fp));
58fseek($fp, 4);
59var_dump(ftell($fp));
60echo 'fseek($fp, -4, SEEK_CUR)';var_dump(fseek($fp, -4, SEEK_CUR));
61var_dump(ftell($fp));
62fseek($fp, 4);
63var_dump(ftell($fp));
64echo 'fseek($fp, 3, SEEK_CUR)';var_dump(fseek($fp, 3, SEEK_CUR));
65var_dump(ftell($fp));
66fclose($fp);
67?>
68--CLEAN--
69<?php
70unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
71exit(0);
72 ?>
73--EXPECT--
74int(0)
75fseek($fp, 1)int(0)
76int(1)
77fseek($fp, 1, SEEK_CUR)int(0)
78int(2)
79fseek($fp, -1, SEEK_CUR)int(0)
80int(1)
81fseek($fp, -1, SEEK_END)int(0)
82int(6)
83fseek($fp, -8, SEEK_END)int(-1)
84bool(false)
85fseek($fp, -7, SEEK_END)int(0)
86int(0)
87fseek($fp, 0, SEEK_END)int(0)
88int(7)
89fseek($fp, 1, SEEK_END)int(-1)
90bool(false)
91fseek($fp, -8, SEEK_END)int(-1)
92bool(false)
93fseek($fp, 6)int(0)
94int(6)
95fseek($fp, 8)int(-1)
96bool(false)
97fseek($fp, -1)int(-1)
98bool(false)
99next
100int(4)
101fseek($fp, -5, SEEK_CUR)int(-1)
102bool(false)
103int(4)
104fseek($fp, 5, SEEK_CUR)int(-1)
105bool(false)
106int(4)
107fseek($fp, -4, SEEK_CUR)int(0)
108int(0)
109int(4)
110fseek($fp, 3, SEEK_CUR)int(0)
111int(7)
112