Annotation of embedaddon/php/ext/phar/tests/phar_metadata_write.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar with metadata (write)
3: --SKIPIF--
4: <?php
5: if (!extension_loaded("phar")) die("skip");
6: if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
7: ?>
8: --INI--
9: phar.require_hash=0
10: phar.readonly=0
11: --FILE--
12: <?php
13: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
14: $pname = 'phar://' . $fname;
15: $file = "<?php __HALT_COMPILER(); ?>";
16:
17: $files = array();
18: $files['a'] = array('cont' => 'a');
19: $files['b'] = array('cont' => 'b', 'meta' => 'hi there');
20: $files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
21: $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
22: include 'files/phar_test.inc';
23:
24: foreach($files as $name => $cont) {
25: var_dump(file_get_contents($pname.'/'.$name));
26: }
27:
28: $phar = new Phar($fname);
29: var_dump($phar->getMetadata());
30: $phar->setMetadata(array('my' => 'friend'));
31: $phar->setMetadata(array('my' => 'friend'));
32: var_dump($phar->getMetadata());
33: $phar['a']->setMetadata(42);
34: $phar['b']->setMetadata(NULL);
35: $phar['c']->setMetadata(array(25, 'foo'=>'bar'));
36: $phar['d']->setMetadata(true);
37:
38: foreach($files as $name => $cont) {
39: var_dump($phar[$name]->getMetadata());
40: }
41:
42: unset($phar);
43:
44: foreach($files as $name => $cont) {
45: var_dump(file_get_contents($pname.'/'.$name));
46: }
47: ?>
48: ===DONE===
49: --CLEAN--
50: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
51: --EXPECT--
52: string(1) "a"
53: string(1) "b"
54: string(1) "c"
55: string(1) "d"
56: NULL
57: array(1) {
58: ["my"]=>
59: string(6) "friend"
60: }
61: int(42)
62: NULL
63: array(2) {
64: [0]=>
65: int(25)
66: ["foo"]=>
67: string(3) "bar"
68: }
69: bool(true)
70: string(1) "a"
71: string(1) "b"
72: string(1) "c"
73: string(1) "d"
74: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>