php-src/ext/phar/tests/refcount1.phpt

47 lines
1.3 KiB
PHP

--TEST--
Phar: test that refcounting avoids problems with deleting a file
--SKIPIF--
<?php if (!extension_loaded("phar")) print "skip"; ?>
<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
--INI--
phar.readonly=0
phar.require_hash=0
--FILE--
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$file = "<?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"; ?>';
include 'phar_test.inc';
$fp = fopen($pname . '/b/c.php', 'wb');
fwrite($fp, "extra\n");
fclose($fp);
$p = new Phar($fname);
$b = fopen($pname . '/b/c.php', 'rb');
$a = $p['b/c.php'];
echo $a;
echo fread($b, 20);
rewind($b);
unlink($pname . '/b/c.php');
echo $a;
echo fread($b, 20);
include $pname . '/b/c.php';
?>
===DONE===
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
extra
extra
Warning: include(phar://%s/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%s" in %s on line %d
Warning: include(): Failed opening 'phar://%s/b/c.php' for inclusion (include_path='%s') in %s on line %d
===DONE===