1--TEST--
2Phar with metadata (write)
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
7?>
8--INI--
9phar.require_hash=0
10phar.readonly=0
11--FILE--
12<?php
13$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
14$pname = 'phar://' . $fname;
15$file = "<?php __HALT_COMPILER(); ?>";
16
17$files = array();
18$files['a'] = array('cont' => 'a');
19$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
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->getMetadata());
30$phar->setMetadata(array('my' => 'friend'));
31$phar->setMetadata(array('my' => 'friend'));
32var_dump($phar->getMetadata());
33$phar['a']->setMetadata(42);
34$phar['b']->setMetadata(NULL);
35$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
36$phar['d']->setMetadata(true);
37
38foreach($files as $name => $cont) {
39	var_dump($phar[$name]->getMetadata());
40}
41
42unset($phar);
43
44foreach($files as $name => $cont) {
45	var_dump(file_get_contents($pname.'/'.$name));
46}
47?>
48===DONE===
49--CLEAN--
50<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
51--EXPECT--
52string(1) "a"
53string(1) "b"
54string(1) "c"
55string(1) "d"
56NULL
57array(1) {
58  ["my"]=>
59  string(6) "friend"
60}
61int(42)
62NULL
63array(2) {
64  [0]=>
65  int(25)
66  ["foo"]=>
67  string(3) "bar"
68}
69bool(true)
70string(1) "a"
71string(1) "b"
72string(1) "c"
73string(1) "d"
74===DONE===
75