xref: /PHP-8.2/ext/phar/tests/019c.phpt (revision 74859783)
1--TEST--
2Phar: opendir test, recurse into
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7--FILE--
8<?php
9$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
10$pname = 'phar://' . $fname;
11$file = "<?php
12Phar::mapPhar('hio');
13__HALT_COMPILER(); ?>";
14
15$files = array();
16$files['a'] = 'a';
17$files['b/a'] = 'b';
18$files['b/c/d'] = 'c';
19$files['bad/c'] = 'd';
20include 'files/phar_test.inc';
21include $fname;
22
23function dump($phar, $base)
24{
25    var_dump($phar . $base);
26    $dir = opendir($phar . $base);
27    if ($base == '/')
28    {
29        $base = '';
30    }
31    while (false !== ($entry = readdir($dir))) {
32        $entry = $base . '/' . $entry;
33        var_dump($entry);
34        var_dump(is_dir($phar . $entry));
35        if (is_dir($phar . $entry))
36        {
37            dump($phar, $entry);
38        }
39        else
40        {
41            var_dump(file_get_contents($phar . $entry));
42        }
43    }
44}
45
46dump('phar://hio', '/');
47
48?>
49--CLEAN--
50<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
51--EXPECT--
52string(11) "phar://hio/"
53string(2) "/a"
54bool(false)
55string(1) "a"
56string(2) "/b"
57bool(true)
58string(12) "phar://hio/b"
59string(4) "/b/a"
60bool(false)
61string(1) "b"
62string(4) "/b/c"
63bool(true)
64string(14) "phar://hio/b/c"
65string(6) "/b/c/d"
66bool(false)
67string(1) "c"
68string(4) "/bad"
69bool(true)
70string(14) "phar://hio/bad"
71string(6) "/bad/c"
72bool(false)
73string(1) "d"
74