xref: /PHP-8.1/ext/phar/tests/phar_stub_write.phpt (revision 74859783)
1--TEST--
2Phar::setStub()/getStub()
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10$fname = __DIR__ . '/' . 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--CLEAN--
45<?php
46unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
47__HALT_COMPILER();
48?>
49--EXPECT--
50string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
51string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
52bool(true)
53string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
54"
55bool(false)
56bool(true)
57string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
58"
59bool(false)
60bool(true)
61bool(false)
62bool(true)
63