xref: /PHP-7.3/ext/phar/tests/phar_stub_write.phpt (revision 782352c5)
1--TEST--
2Phar::setStub()/getStub()
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
11$pname = 'phar://' . $fname;
12$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
13$file = $stub;
14
15$files = array();
16$files['a'] = 'a';
17$files['b'] = 'b';
18$files['c'] = 'c';
19
20include 'files/phar_test.inc';
21
22$phar = new Phar($fname);
23var_dump($stub);
24var_dump($phar->getStub());
25var_dump($phar->getStub() == $stub);
26
27$stub = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
28$sexp = $stub . "\r\n";
29
30$phar->setStub($stub);
31var_dump($phar->getStub());
32var_dump($phar->getStub() == $stub);
33var_dump($phar->getStub() == $sexp);
34$phar->stopBuffering();
35var_dump($phar->getStub());
36var_dump($phar->getStub() == $stub);
37var_dump($phar->getStub() == $sexp);
38
39$phar = new Phar($fname);
40var_dump($phar->getStub() == $stub);
41var_dump($phar->getStub() == $sexp);
42
43?>
44===DONE===
45--CLEAN--
46<?php
47unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
48__HALT_COMPILER();
49?>
50--EXPECT--
51string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
52string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
53bool(true)
54string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
55"
56bool(false)
57bool(true)
58string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
59"
60bool(false)
61bool(true)
62bool(false)
63bool(true)
64===DONE===
65