1--TEST--
2Phar with metadata (write)
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.require_hash=0
9phar.readonly=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$files['a'] = array('cont' => 'a');
18$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
19$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
20$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
21include 'files/phar_test.inc';
22
23foreach($files as $name => $cont) {
24	var_dump(file_get_contents($pname.'/'.$name));
25}
26
27$phar = new Phar($fname);
28var_dump($phar->getMetadata());
29$phar->setMetadata(array('my' => 'friend'));
30$phar->setMetadata(array('my' => 'friend'));
31var_dump($phar->getMetadata());
32$phar['a']->setMetadata(42);
33$phar['b']->setMetadata(NULL);
34$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
35$phar['d']->setMetadata(true);
36
37foreach($files as $name => $cont) {
38	var_dump($phar[$name]->getMetadata());
39}
40
41unset($phar);
42
43foreach($files as $name => $cont) {
44	var_dump(file_get_contents($pname.'/'.$name));
45}
46?>
47===DONE===
48--CLEAN--
49<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
50--EXPECT--
51string(1) "a"
52string(1) "b"
53string(1) "c"
54string(1) "d"
55NULL
56array(1) {
57  ["my"]=>
58  string(6) "friend"
59}
60int(42)
61NULL
62array(2) {
63  [0]=>
64  int(25)
65  ["foo"]=>
66  string(3) "bar"
67}
68bool(true)
69string(1) "a"
70string(1) "b"
71string(1) "c"
72string(1) "d"
73===DONE===
74