1--TEST--
2Phar with metadata (read)
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.readonly=0
9phar.require_hash=0
10--FILE--
11<?php
12$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
13$pname = 'phar://' . $fname;
14$file = "<?php __HALT_COMPILER(); ?>";
15
16$files = array();
17$pmeta = 'hi there';
18$files['a'] = array('cont' => 'a');
19$files['b'] = array('cont' => 'b');
20$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
21$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
22include 'files/phar_test.inc';
23
24foreach($files as $name => $cont) {
25	var_dump(file_get_contents($pname.'/'.$name));
26}
27
28$phar = new Phar($fname);
29var_dump($phar->hasMetaData());
30var_dump($phar->getMetaData());
31var_dump($phar->delMetaData());
32var_dump($phar->getMetaData());
33var_dump($phar->delMetaData());
34var_dump($phar->getMetaData());
35foreach($files as $name => $cont) {
36	echo "  meta $name\n";
37	var_dump($phar[$name]->hasMetadata());
38	var_dump($phar[$name]->getMetadata());
39	var_dump($phar[$name]->delMetadata());
40	var_dump($phar[$name]->getMetadata());
41}
42
43unset($phar);
44
45foreach($files as $name => $cont) {
46	var_dump(file_get_contents($pname.'/'.$name));
47}
48?>
49===DONE===
50--CLEAN--
51<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
52--EXPECT--
53string(1) "a"
54string(1) "b"
55string(1) "c"
56string(1) "d"
57bool(true)
58string(8) "hi there"
59bool(true)
60NULL
61bool(true)
62NULL
63  meta a
64bool(false)
65NULL
66bool(true)
67NULL
68  meta b
69bool(false)
70NULL
71bool(true)
72NULL
73  meta c
74bool(true)
75array(2) {
76  [0]=>
77  string(2) "hi"
78  [1]=>
79  string(5) "there"
80}
81bool(true)
82NULL
83  meta d
84bool(true)
85array(2) {
86  ["hi"]=>
87  string(5) "there"
88  ["foo"]=>
89  string(3) "bar"
90}
91bool(true)
92NULL
93string(1) "a"
94string(1) "b"
95string(1) "c"
96string(1) "d"
97===DONE===
98