1--TEST--
2Phar::setStub()/getStub() from file
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.readonly=0
8allow_url_fopen=1
9--FILE--
10<?php
11$fname = dirname(__FILE__) . '/' . 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===DONE===
46--CLEAN--
47<?php
48unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
49__HALT_COMPILER();
50?>
51--EXPECT--
52string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
53string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
54bool(true)
55string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
56"
57bool(false)
58bool(true)
59string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
60"
61bool(false)
62bool(true)
63bool(false)
64bool(true)
65===DONE===
66