xref: /php-src/ext/phar/tests/opendir.phpt (revision 74859783)
1--TEST--
2Phar: test opendir() interception
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=1
7phar.readonly=0
8--FILE--
9<?php
10$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
11$a = new Phar($fname);
12$a['index.php'] = '<?php
13$a = opendir("dir");
14if ($a) {
15    while (false !== ($e = readdir($a))) {
16        echo $e;
17    }
18}
19?>';
20$a['dir/file1.txt'] = 'hi';
21$a['dir/file2.txt'] = 'hi2';
22$a['dir/file3.txt'] = 'hi3';
23$a->setStub('<?php
24Phar::interceptFileFuncs();
25set_include_path("phar://" . __FILE__);
26include "index.php";
27__HALT_COMPILER();');
28include $fname;
29echo "\n";
30opendir('phar://');
31opendir('phar://hi.phar');
32?>
33--CLEAN--
34<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
35--EXPECTF--
36file1.txtfile2.txtfile3.txt
37
38Warning: opendir(phar://): Failed to open directory: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar)
39phar url "phar://" is unknown in %sopendir.php on line %d
40
41Warning: opendir(phar://hi.phar): Failed to open directory: phar error: invalid url or non-existent phar "phar://hi.phar"
42phar url "phar://hi.phar" is unknown in %sopendir.php on line %d
43