1--TEST--
2Phar::buildFromDirectory() with matching regex
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11mkdir(dirname(__FILE__).'/testdir5');
12foreach(range(1, 4) as $i) {
13    file_put_contents(dirname(__FILE__)."/testdir5/file$i.txt", "some content for file $i");
14}
15
16try {
17	$phar = new Phar(dirname(__FILE__) . '/buildfromdirectory5.phar');
18	$a = $phar->buildFromDirectory(dirname(__FILE__) . '/testdir5', '/\.txt/');
19	asort($a);
20	var_dump($a);
21} catch (Exception $e) {
22	var_dump(get_class($e));
23	echo $e->getMessage() . "\n";
24}
25
26var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory5.phar'));
27
28?>
29===DONE===
30--CLEAN--
31<?php
32unlink(dirname(__FILE__) . '/buildfromdirectory5.phar');
33foreach(range(1, 4) as $i) {
34    unlink(dirname(__FILE__) . "/testdir5/file$i.txt");
35}
36rmdir(dirname(__FILE__) . '/testdir5');
37?>
38--EXPECTF--
39array(4) {
40  ["file1.txt"]=>
41  string(%d) "%stestdir5%cfile1.txt"
42  ["file2.txt"]=>
43  string(%d) "%stestdir5%cfile2.txt"
44  ["file3.txt"]=>
45  string(%d) "%stestdir5%cfile3.txt"
46  ["file4.txt"]=>
47  string(%d) "%stestdir5%cfile4.txt"
48}
49bool(true)
50===DONE===
51