Annotation of embedaddon/php/ext/phar/tests/metadata_write_commit.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->startBuffering();
30: $phar['a']->setMetadata(42);
31: $phar['b']->setMetadata(NULL);
32: $phar['c']->setMetadata(array(25, 'foo'=>'bar'));
33: $phar['d']->setMetadata(true);
34:
35: foreach($files as $name => $cont) {
36: var_dump($phar[$name]->getMetadata());
37: }
38: $phar->stopBuffering();
39:
40: unset($phar);
41:
42: $phar = new Phar($fname);
43:
44: foreach($files as $name => $cont) {
45: var_dump(file_get_contents($pname.'/'.$name));
46: }
47:
48: foreach($files as $name => $cont) {
49: var_dump($phar[$name]->getMetadata());
50: }
51: ?>
52: ===DONE===
53: --CLEAN--
54: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
55: --EXPECT--
56: string(1) "a"
57: string(1) "b"
58: string(1) "c"
59: string(1) "d"
60: int(42)
61: NULL
62: array(2) {
63: [0]=>
64: int(25)
65: ["foo"]=>
66: string(3) "bar"
67: }
68: bool(true)
69: string(1) "a"
70: string(1) "b"
71: string(1) "c"
72: string(1) "d"
73: int(42)
74: NULL
75: array(2) {
76: [0]=>
77: int(25)
78: ["foo"]=>
79: string(3) "bar"
80: }
81: bool(true)
82: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>