Browse Source
- Verify stub
- Verify stub
- Automatically cut off stub after __HALT_COMPILER(); - Always write longest stub ending, so there is no issue with length field - Add test for setStub from file - Fix testsPHAR_1_2
5 changed files with 129 additions and 37 deletions
-
68ext/phar/phar.c
-
11ext/phar/tests/phar_begin_setstub_commit.phpt
-
9ext/phar/tests/phar_commitwrite.phpt
-
14ext/phar/tests/phar_stub_write.phpt
-
64ext/phar/tests/phar_stub_write_file.phpt
@ -0,0 +1,64 @@ |
|||
--TEST-- |
|||
Phar::setStub()/getStub() from file |
|||
--SKIPIF-- |
|||
<?php if (!extension_loaded("phar")) print "skip"; ?> |
|||
--INI-- |
|||
phar.require_hash=0 |
|||
phar.readonly=0 |
|||
--FILE-- |
|||
<?php |
|||
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; |
|||
$pname = 'phar://' . $fname; |
|||
$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>'; |
|||
$file = $stub; |
|||
|
|||
$files = array(); |
|||
$files['a'] = 'a'; |
|||
$files['b'] = 'b'; |
|||
$files['c'] = 'c'; |
|||
|
|||
include 'phar_test.inc'; |
|||
|
|||
$phar = new Phar($fname); |
|||
var_dump($stub); |
|||
var_dump($phar->getStub()); |
|||
var_dump($phar->getStub() == $stub); |
|||
|
|||
$stub = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>'; |
|||
$sexp = $stub . "\r\n"; |
|||
$stub = fopen('data://,'.$stub, 'r'); |
|||
$phar->setStub($stub); |
|||
var_dump($phar->getStub()); |
|||
var_dump($phar->getStub() == $stub); |
|||
var_dump($phar->getStub() == $sexp); |
|||
$phar->stopBuffering(); |
|||
var_dump($phar->getStub()); |
|||
var_dump($phar->getStub() == $stub); |
|||
var_dump($phar->getStub() == $sexp); |
|||
|
|||
$phar = new Phar($fname); |
|||
var_dump($phar->getStub() == $stub); |
|||
var_dump($phar->getStub() == $sexp); |
|||
|
|||
?> |
|||
===DONE=== |
|||
--CLEAN-- |
|||
<?php |
|||
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); |
|||
__HALT_COMPILER(); |
|||
?> |
|||
--EXPECT-- |
|||
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>" |
|||
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>" |
|||
bool(true) |
|||
string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?> |
|||
" |
|||
bool(false) |
|||
bool(true) |
|||
string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?> |
|||
" |
|||
bool(false) |
|||
bool(true) |
|||
bool(false) |
|||
bool(true) |
|||
===DONE=== |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue