xref: /PHP-8.2/ext/phar/tests/019b.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    }
40}
41
42dump('phar://hio', '/');
43
44?>
45--CLEAN--
46<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
47--EXPECT--
48string(11) "phar://hio/"
49string(2) "/a"
50bool(false)
51string(2) "/b"
52bool(true)
53string(12) "phar://hio/b"
54string(4) "/b/a"
55bool(false)
56string(4) "/b/c"
57bool(true)
58string(14) "phar://hio/b/c"
59string(6) "/b/c/d"
60bool(false)
61string(4) "/bad"
62bool(true)
63string(14) "phar://hio/bad"
64string(6) "/bad/c"
65bool(false)
66