Annotation of embedaddon/php/ext/phar/tests/tar/phar_stub.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar::setStub() (tar-based)
3: --SKIPIF--
4: <?php if (!extension_loaded("phar")) die("skip"); ?>
5: --INI--
6: phar.require_hash=0
7: phar.readonly=0
8: --FILE--
9: <?php
10: $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar.php';
11: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
12: $pname = 'phar://' . $fname;
13: $pname2 = 'phar://' . $fname2;
14:
15: $p = new Phar($pname2);
16: $p->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
17: $p['a'] = 'a';
18: $p['b'] = 'b';
19: $p['c'] = 'c';
20: copy($fname2, $fname);
21:
22: $phar = new Phar($fname);
23: echo $phar->getStub();
24:
25: $file = b'<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
26:
27: //// 2
28: $phar->setStub($file);
29: echo $phar->getStub();
30:
31: $fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phartmp.php';
32: $file = b'<?php echo "third stub\n"; __HALT_COMPILER(); ?>';
33: $fp = fopen($fname3, 'wb');
34: fwrite($fp, $file);
35: fclose($fp);
36: $fp = fopen($fname3, 'rb');
37:
38: //// 3
39: $phar->setStub($fp);
40: fclose($fp);
41:
42: echo $phar->getStub();
43:
44: $fp = fopen($fname3, 'ab');
45: fwrite($fp, b'booya');
46: fclose($fp);
47: echo file_get_contents($fname3) . "\n";
48:
49: $fp = fopen($fname3, 'rb');
50:
51: //// 4
52: $phar->setStub($fp, strlen($file));
53: fclose($fp);
54: echo $phar->getStub();
55:
56: $phar['testing'] = 'hi';
57:
58: echo $phar->getStub();
59: ?>
60: ===DONE===
61: --CLEAN--
62: <?php
63: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php');
64: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar.php');
65: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
66: __HALT_COMPILER();
67: ?>
68: --EXPECT--
69: <?php echo "first stub\n"; __HALT_COMPILER(); ?>
70: <?php echo "second stub\n"; __HALT_COMPILER(); ?>
71: <?php echo "third stub\n"; __HALT_COMPILER(); ?>
72: <?php echo "third stub\n"; __HALT_COMPILER(); ?>booya
73: <?php echo "third stub\n"; __HALT_COMPILER(); ?>
74: <?php echo "third stub\n"; __HALT_COMPILER(); ?>
75: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>