xref: /PHP-8.0/ext/phar/tests/metadata_read.phpt (revision f8d79582)
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 = __DIR__ . '/' . 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--CLEAN--
38<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
39--EXPECT--
40string(1) "a"
41string(1) "b"
42string(1) "c"
43string(1) "d"
44NULL
45string(8) "hi there"
46array(2) {
47  [0]=>
48  string(2) "hi"
49  [1]=>
50  string(5) "there"
51}
52array(2) {
53  ["hi"]=>
54  string(5) "there"
55  ["foo"]=>
56  string(3) "bar"
57}
58string(1) "a"
59string(1) "b"
60string(1) "c"
61string(1) "d"
62