xref: /PHP-5.3/ext/phar/tests/phar_oo_007.phpt (revision 610c7fbe)
1--TEST--
2Phar object: access through SplFileObject
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
6--INI--
7phar.require_hash=0
8--FILE--
9<?php
10
11require_once 'files/phar_oo_test.inc';
12
13class MyFile extends SplFileObject
14{
15	function __construct($name)
16	{
17		echo __METHOD__ . "(" . str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name) . ")\n";
18		parent::__construct($name);
19	}
20}
21
22$phar = new Phar($fname);
23$phar->setInfoClass('MyFile');
24
25$f = $phar['a.php'];
26
27$s = $f->fstat();
28
29var_dump($s['atime']);
30var_dump($s['ctime']);
31var_dump($s['mtime']);
32
33var_dump($f->ftell());
34var_dump($f->eof());
35var_dump($f->fgets());
36var_dump($f->eof());
37var_dump($f->fseek(20));
38var_dump($f->ftell());
39var_dump($f->fgets());
40var_dump($f->rewind());
41var_dump($f->ftell());
42var_dump($f->fgets());
43var_dump($f->ftell());
44
45?>
46===AGAIN===
47<?php
48
49$f = $phar['a.php'];
50
51var_dump($f->ftell());
52var_dump($f->eof());
53var_dump($f->fgets());
54var_dump($f->eof());
55
56//unset($f); without unset we check for working refcounting
57
58?>
59===DONE===
60--CLEAN--
61<?php
62unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
63__halt_compiler();
64?>
65--EXPECTF--
66MyFile::__construct(phar://*/files/phar_oo_test.phar.php/a.php)
67int(%d)
68int(%d)
69int(%d)
70int(0)
71bool(false)
72string(32) "<?php echo "This is a.php\n"; ?>"
73bool(true)
74int(0)
75int(20)
76string(12) "a.php\n"; ?>"
77NULL
78int(0)
79string(32) "<?php echo "This is a.php\n"; ?>"
80int(32)
81===AGAIN===
82MyFile::__construct(phar://*/files/phar_oo_test.phar.php/a.php)
83int(0)
84bool(false)
85string(32) "<?php echo "This is a.php\n"; ?>"
86bool(true)
87===DONE===
88