1--TEST--
2Phar::setStub()/getStub() from file
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8allow_url_fopen=1
9--FILE--
10<?php
11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
12$pname = 'phar://' . $fname;
13$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
14$file = $stub;
15
16$files = array();
17$files['a'] = 'a';
18$files['b'] = 'b';
19$files['c'] = 'c';
20
21include 'files/phar_test.inc';
22
23$phar = new Phar($fname);
24var_dump($stub);
25var_dump($phar->getStub());
26var_dump($phar->getStub() == $stub);
27
28$stub = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
29$sexp = $stub . "\r\n";
30$stub = fopen('data://,'.$stub, 'r');
31$phar->setStub($stub);
32var_dump($phar->getStub());
33var_dump($phar->getStub() == $stub);
34var_dump($phar->getStub() == $sexp);
35$phar->stopBuffering();
36var_dump($phar->getStub());
37var_dump($phar->getStub() == $stub);
38var_dump($phar->getStub() == $sexp);
39
40$phar = new Phar($fname);
41var_dump($phar->getStub() == $stub);
42var_dump($phar->getStub() == $sexp);
43
44?>
45--CLEAN--
46<?php
47unlink(__DIR__ . '/' . 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