xref: /PHP-7.2/ext/phar/tests/phar_oo_002.phpt (revision 17ccbeec)
1--TEST--
2Phar object: iterator & entries
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6if (!extension_loaded("spl")) die("skip SPL not available");
7?>
8--INI--
9phar.readonly=1
10phar.require_hash=0
11--FILE--
12<?php
13
14require_once 'files/phar_oo_test.inc';
15
16$phar = new Phar($fname);
17$phar->setInfoClass('SplFileInfo');
18foreach($phar as $name => $ent)
19{
20	var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
21	var_dump($ent->getFilename());
22	var_dump($ent->getSize());
23	var_dump($ent->getType());
24	var_dump($ent->isWritable());
25	var_dump($ent->isReadable());
26	var_dump($ent->isExecutable());
27	var_dump($ent->isFile());
28	var_dump($ent->isDir());
29	var_dump($ent->isLink());
30	var_dump($ent->getCTime());
31	var_dump($ent->getMTime());
32	var_dump($ent->getATime());
33}
34
35echo "==RECURSIVE==\n";
36
37$phar = new Phar($fname);
38foreach(new RecursiveIteratorIterator($phar) as $name => $ent)
39{
40	var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
41	var_dump(str_replace('\\', '/', $ent->getFilename()));
42	var_dump($ent->getCompressedSize());
43	var_dump($ent->isCRCChecked());
44	var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL);
45	var_dump($ent->getPharFlags());
46}
47
48?>
49===DONE===
50--CLEAN--
51<?php
52unlink(dirname(__FILE__) . '/files/phar_oo_002.phar.php');
53__halt_compiler();
54?>
55--EXPECTF--
56string(41) "phar://*/files/phar_oo_002.phar.php%ca.php"
57string(5) "a.php"
58int(32)
59string(4) "file"
60bool(false)
61bool(true)
62bool(false)
63bool(true)
64bool(false)
65bool(false)
66int(%d)
67int(%d)
68int(%d)
69string(37) "phar://*/files/phar_oo_002.phar.php%cb"
70string(1) "b"
71int(0)
72string(3) "dir"
73bool(false)
74bool(true)
75bool(false)
76bool(false)
77bool(true)
78bool(false)
79int(%d)
80int(%d)
81int(%d)
82string(41) "phar://*/files/phar_oo_002.phar.php%cb.php"
83string(5) "b.php"
84int(32)
85string(4) "file"
86bool(false)
87bool(true)
88bool(false)
89bool(true)
90bool(false)
91bool(false)
92int(%d)
93int(%d)
94int(%d)
95string(41) "phar://*/files/phar_oo_002.phar.php%ce.php"
96string(5) "e.php"
97int(32)
98string(4) "file"
99bool(false)
100bool(true)
101bool(false)
102bool(true)
103bool(false)
104bool(false)
105int(%d)
106int(%d)
107int(%d)
108==RECURSIVE==
109string(41) "phar://*/files/phar_oo_002.phar.php%ca.php"
110string(5) "a.php"
111int(32)
112bool(false)
113NULL
114int(0)
115string(43) "phar://*/files/phar_oo_002.phar.php/b%cc.php"
116string(5) "c.php"
117int(34)
118bool(false)
119NULL
120int(0)
121string(43) "phar://*/files/phar_oo_002.phar.php/b%cd.php"
122string(5) "d.php"
123int(34)
124bool(false)
125NULL
126int(0)
127string(41) "phar://*/files/phar_oo_002.phar.php%cb.php"
128string(5) "b.php"
129int(32)
130bool(false)
131NULL
132int(0)
133string(41) "phar://*/files/phar_oo_002.phar.php%ce.php"
134string(5) "e.php"
135int(32)
136bool(false)
137NULL
138int(0)
139===DONE===
140