Annotation of embedaddon/php/ext/phar/tests/metadata_write.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar with meta-data (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: $phar['a']->setMetadata(42);
30: $phar['b']->setMetadata(NULL);
31: $phar['c']->setMetadata(array(25, 'foo'=>'bar'));
32: $phar['d']->setMetadata(true);
33:
34: foreach($files as $name => $cont) {
35: var_dump($phar[$name]->getMetadata());
36: }
37:
38: unset($phar);
39:
40: foreach($files as $name => $cont) {
41: var_dump(file_get_contents($pname.'/'.$name));
42: }
43: ?>
44: ===DONE===
45: --CLEAN--
46: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
47: --EXPECT--
48: string(1) "a"
49: string(1) "b"
50: string(1) "c"
51: string(1) "d"
52: int(42)
53: NULL
54: array(2) {
55: [0]=>
56: int(25)
57: ["foo"]=>
58: string(3) "bar"
59: }
60: bool(true)
61: string(1) "a"
62: string(1) "b"
63: string(1) "c"
64: string(1) "d"
65: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>