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