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