xref: /PHP-5.4/ext/phar/tests/metadata_readU.phpt (revision 377ff97a)
1--TEST--
2Phar with meta-data (read)
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
7?>
8--INI--
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$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);
28foreach($files as $name => $cont) {
29	var_dump($phar[$name]->getMetadata());
30}
31
32unset($phar);
33
34foreach($files as $name => $cont) {
35	var_dump(file_get_contents($pname.'/'.$name));
36}
37?>
38===DONE===
39--CLEAN--
40<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
41--EXPECT--
42string(1) "a"
43string(1) "b"
44string(1) "c"
45string(1) "d"
46NULL
47unicode(8) "hi there"
48array(2) {
49  [0]=>
50  unicode(2) "hi"
51  [1]=>
52  unicode(5) "there"
53}
54array(2) {
55  [u"hi"]=>
56  unicode(5) "there"
57  [u"foo"]=>
58  unicode(3) "bar"
59}
60string(1) "a"
61string(1) "b"
62string(1) "c"
63string(1) "d"
64===DONE===
65