mirror of
https://github.com/php/php-src.git
synced 2024-10-03 15:56:11 +00:00
b93b48663d
fix a whole bunch of zip-related bugs tar tests need some naming add phar information to error messages, fix existing tests to reflect this
62 lines
1.5 KiB
PHP
Executable File
62 lines
1.5 KiB
PHP
Executable File
--TEST--
|
|
Phar::setStub()/getStub() tar-based
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
|
--INI--
|
|
phar.require_hash=0
|
|
phar.readonly=0
|
|
--FILE--
|
|
<?php
|
|
include dirname(__FILE__) . '/tarmaker.php.inc';
|
|
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
|
|
$pname = 'phar://' . $fname;
|
|
$a = new tarmaker($fname, 'none');
|
|
$a->init();
|
|
$a->addFile('.phar/stub.php', $stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
|
|
|
|
$files = array();
|
|
$files['a'] = 'a';
|
|
$files['.phar/alias.txt'] = 'hio';
|
|
foreach ($files as $n => $file) {
|
|
$a->addFile($n, $file);
|
|
}
|
|
$a->close();
|
|
|
|
$phar = new Phar($fname);
|
|
var_dump($stub);
|
|
var_dump($phar->getStub());
|
|
var_dump($phar->getStub() == $stub);
|
|
|
|
$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
|
|
try
|
|
{
|
|
$phar->setStub($newstub);
|
|
}
|
|
catch(exception $e)
|
|
{
|
|
echo 'Exception: ' . $e->getMessage() . "\n";
|
|
}
|
|
var_dump($phar->getStub());
|
|
var_dump($phar->getStub() == $stub);
|
|
$phar->stopBuffering();
|
|
var_dump($phar->getStub());
|
|
var_dump($phar->getStub() == $stub);
|
|
|
|
?>
|
|
===DONE===
|
|
--CLEAN--
|
|
<?php
|
|
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
|
|
__HALT_COMPILER();
|
|
?>
|
|
--EXPECTF--
|
|
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
|
|
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
|
|
bool(true)
|
|
Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.php"
|
|
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
|
|
bool(true)
|
|
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
|
|
bool(true)
|
|
===DONE===
|