xref: /PHP-7.3/ext/phar/tests/opendir.phpt (revision b746e698)
1--TEST--
2Phar: test opendir() interception
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip");?>
5--INI--
6phar.require_hash=1
7phar.readonly=0
8--FILE--
9<?php
10$fname = dirname(__FILE__) . '/' . 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===DONE===
34--CLEAN--
35<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
36--EXPECTF--
37file1.txtfile2.txtfile3.txt
38
39Warning: opendir(phar://): failed to open dir: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar)
40phar url "phar://" is unknown in %sopendir.php on line %d
41
42Warning: opendir(phar://hi.phar): failed to open dir: phar error: invalid url or non-existent phar "phar://hi.phar"
43phar url "phar://hi.phar" is unknown in %sopendir.php on line %d
44===DONE===
45