Annotation of embedaddon/php/ext/phar/tests/phar_ctx_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar context
3: --SKIPIF--
4: <?php if (!extension_loaded("phar")) die("skip"); ?>
5: <?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
6: --INI--
7: phar.require_hash=0
8: phar.readonly=0
9: --FILE--
10: <?php
11: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
12: $pname = 'phar://' . $fname;
13: $file = '<?php __HALT_COMPILER(); ?>';
14:
15: $files = array();
16: $files['a'] = 'a';
17: $files['b'] = 'b';
18: $files['c'] = 'c';
19:
20: include 'files/phar_test.inc';
21:
22: $phar = new Phar($fname);
23:
24: var_dump(file_get_contents($pname . '/a'));
25: var_dump($phar['a']->isCompressed());
26: var_dump(file_get_contents($pname . '/b'));
27: var_dump($phar['b']->isCompressed());
28: var_dump(file_get_contents($pname . '/c'));
29: var_dump($phar['c']->isCompressed());
30:
31: $context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, b'hi' => 3))));
32: $context2 = stream_context_create(array('phar' => array('metadata' => array(4))));
33:
34: file_put_contents($pname . '/a', b'new a', 0); // no compression
35: file_put_contents($pname . '/b', b'new b', 0, $context);
36: file_put_contents($pname . '/d', b'new d', 0, $context2);
37:
38: $phar = new Phar($fname);
39: var_dump(file_get_contents($pname . '/a'));
40: var_dump($phar['a']->isCompressed());
41: var_dump($phar['a']->getMetaData());
42: var_dump(file_get_contents($pname . '/b'));
43: var_dump($phar['b']->isCompressed());
44: var_dump($phar['b']->getMetaData());
45: var_dump(file_get_contents($pname . '/c'));
46: var_dump($phar['c']->isCompressed());
47: var_dump($phar['c']->getMetaData());
48: var_dump(file_get_contents($pname . '/d'));
49: var_dump($phar['d']->isCompressed());
50: var_dump($phar['d']->getMetaData());
51: $context2 = stream_context_create(array('phar' => array('metadata' => array(4))));
52: $fp = fopen($pname . '/b', 'r+', 0, $context2);
53: fclose($fp);
54: ?>
55: ==AFTER==
56: <?php
57: var_dump(file_get_contents($pname . '/b'));
58: var_dump($phar['b']->isCompressed());
59: var_dump($phar['b']->getMetaData());
60: ?>
61: ===DONE===
62: --CLEAN--
63: <?php
64: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
65: ?>
66: --EXPECT--
67: string(1) "a"
68: bool(false)
69: string(1) "b"
70: bool(false)
71: string(1) "c"
72: bool(false)
73: string(5) "new a"
74: bool(false)
75: NULL
76: string(5) "new b"
77: bool(true)
78: array(2) {
79: [0]=>
80: int(2)
81: ["hi"]=>
82: int(3)
83: }
84: string(1) "c"
85: bool(false)
86: NULL
87: string(5) "new d"
88: bool(false)
89: array(1) {
90: [0]=>
91: int(4)
92: }
93: ==AFTER==
94: string(5) "new b"
95: bool(true)
96: array(1) {
97: [0]=>
98: int(4)
99: }
100: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>