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