xref: /PHP-7.1/ext/phar/tests/metadata_read.phpt (revision e3de409e)
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 pre-unicode version of PHP 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
47string(8) "hi there"
48array(2) {
49  [0]=>
50  string(2) "hi"
51  [1]=>
52  string(5) "there"
53}
54array(2) {
55  ["hi"]=>
56  string(5) "there"
57  ["foo"]=>
58  string(3) "bar"
59}
60string(1) "a"
61string(1) "b"
62string(1) "c"
63string(1) "d"
64===DONE===
65