Annotation of embedaddon/php/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar::startBuffering()/setStub()/stopBuffering() zip-based
3: --SKIPIF--
4: <?php
5: if (!extension_loaded("phar")) die("skip");
6: if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
7: ?>
8: --INI--
9: phar.readonly=0
10: --FILE--
11: <?php
12: $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.zip', 0, 'brandnewphar.phar');
13: var_dump($p->isFileFormat(Phar::ZIP));
14: //var_dump($p->getStub());
15: var_dump($p->isBuffering());
16: $p->startBuffering();
17: var_dump($p->isBuffering());
18: $p['a.php'] = '<?php var_dump("Hello");';
19: $p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
20: include 'phar://brandnewphar.phar/a.php';
21: var_dump($p->getStub());
22: $p['b.php'] = '<?php var_dump("World");';
23: $p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
24: include 'phar://brandnewphar.phar/b.php';
25: var_dump($p->getStub());
26: $p->stopBuffering();
27: echo "===COMMIT===\n";
28: var_dump($p->isBuffering());
29: include 'phar://brandnewphar.phar/a.php';
30: include 'phar://brandnewphar.phar/b.php';
31: var_dump($p->getStub());
32:
33: // add portion to test setting stub from resource
34: file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
35: $a = fopen(dirname(__FILE__) . '/myfakestub.php', 'rb');
36: $p->setStub($a);
37: var_dump($p->getStub());
38: $c = strlen('<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
39: file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>' . 'extra stuff');
40: fseek($a, 0);
41: $p->setStub($a, $c);
42: var_dump($p->getStub());
43: fclose($a);
44: ?>
45: ===DONE===
46: --CLEAN--
47: <?php
48: unlink(dirname(__FILE__) . '/brandnewphar.phar.zip');
49: unlink(dirname(__FILE__) . '/myfakestub.php');
50: ?>
51: --EXPECT--
52: bool(true)
53: bool(false)
54: bool(true)
55: unicode(5) "Hello"
56: string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
57: "
58: unicode(5) "World"
59: string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
60: "
61: ===COMMIT===
62: bool(false)
63: unicode(5) "Hello"
64: unicode(5) "World"
65: string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
66: "
67: string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
68: "
69: string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
70: "
71: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>