xref: /PHP-7.2/ext/phar/tests/metadata_read.phpt (revision 442fd2f9)
1--TEST--
2Phar with meta-data (read)
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.require_hash=0
9--FILE--
10<?php
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
12$pname = 'phar://' . $fname;
13$file = "<?php __HALT_COMPILER(); ?>";
14
15$files = array();
16$files['a'] = array('cont' => 'a');
17$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
18$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
19$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
20include 'files/phar_test.inc';
21
22foreach($files as $name => $cont) {
23	var_dump(file_get_contents($pname.'/'.$name));
24}
25
26$phar = new Phar($fname);
27foreach($files as $name => $cont) {
28	var_dump($phar[$name]->getMetadata());
29}
30
31unset($phar);
32
33foreach($files as $name => $cont) {
34	var_dump(file_get_contents($pname.'/'.$name));
35}
36?>
37===DONE===
38--CLEAN--
39<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
40--EXPECT--
41string(1) "a"
42string(1) "b"
43string(1) "c"
44string(1) "d"
45NULL
46string(8) "hi there"
47array(2) {
48  [0]=>
49  string(2) "hi"
50  [1]=>
51  string(5) "there"
52}
53array(2) {
54  ["hi"]=>
55  string(5) "there"
56  ["foo"]=>
57  string(3) "bar"
58}
59string(1) "a"
60string(1) "b"
61string(1) "c"
62string(1) "d"
63===DONE===
64