mirror of
https://github.com/php/php-src.git
synced 2024-10-03 07:46:12 +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
64 lines
1.7 KiB
PHP
Executable File
64 lines
1.7 KiB
PHP
Executable File
--TEST--
|
|
Phar: test that refcounting avoids problems with deleting a file zip-based
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
|
<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
|
|
<?php if (version_compare(PHP_VERSION, "5.2", ">")) die("skip requires 5.2 or earlier"); ?>
|
|
<?php if (!extension_loaded("zip")) die("skip"); ?>
|
|
--INI--
|
|
phar.readonly=0
|
|
phar.require_hash=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', "<?php __HALT_COMPILER(); ?>");
|
|
|
|
|
|
$files = array();
|
|
$files['a.php'] = '<?php echo "This is a\n"; ?>';
|
|
$files['b.php'] = '<?php echo "This is b\n"; ?>';
|
|
$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
|
|
$files['.phar/alias.txt'] = 'hio';
|
|
foreach ($files as $n => $file) {
|
|
$a->addFile($n, $file);
|
|
}
|
|
$a->close();
|
|
|
|
$fp = fopen($pname . '/b/c.php', 'wb');
|
|
fwrite($fp, "extra");
|
|
fclose($fp);
|
|
echo "===CLOSE===\n";
|
|
$p = new Phar($fname);
|
|
$b = fopen($pname . '/b/c.php', 'rb');
|
|
$a = $p['b/c.php'];
|
|
var_dump($a);
|
|
var_dump(fread($b, 20));
|
|
rewind($b);
|
|
echo "===UNLINK===\n";
|
|
unlink($pname . '/b/c.php');
|
|
var_dump($a);
|
|
var_dump(fread($b, 20));
|
|
include $pname . '/b/c.php';
|
|
?>
|
|
|
|
===DONE===
|
|
--CLEAN--
|
|
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
|
|
--EXPECTF--
|
|
===CLOSE===
|
|
object(PharFileInfo)#%d (0) {
|
|
}
|
|
string(5) "extra"
|
|
===UNLINK===
|
|
|
|
Warning: unlink(): phar error: "b/c.php" in phar "%sefcount1.phar.php", has open file pointers, cannot unlink in %sefcount1.php on line %d
|
|
object(PharFileInfo)#%d (0) {
|
|
}
|
|
string(5) "extra"
|
|
extra
|
|
===DONE===
|