php-src/ext/phar/tests/tar/open_for_write_newfile.phpt

45 lines
926 B
Plaintext
Raw Normal View History

2008-01-07 17:40:43 +00:00
--TEST--
Phar: fopen a .phar for writing (new file) tar-based
2008-01-07 17:40:43 +00:00
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
phar.readonly=0
phar.require_hash=0
--FILE--
<?php
2008-02-12 16:39:59 +00:00
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
$alias = 'phar://' . $fname;
$phar = new Phar($fname);
$phar->setStub("<?php __HALT_COMPILER(); ?>");
2008-01-07 17:40:43 +00:00
$files = array();
2008-02-12 16:39:59 +00:00
2008-01-07 17:40:43 +00:00
$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"; ?>';
2008-02-12 16:39:59 +00:00
2008-01-07 17:40:43 +00:00
foreach ($files as $n => $file) {
2008-02-12 16:39:59 +00:00
$phar[$n] = $file;
2008-01-07 17:40:43 +00:00
}
2008-02-12 16:39:59 +00:00
$phar->stopBuffering();
$fp = fopen($alias . '/b/new.php', 'wb');
fwrite($fp, (binary)'extra');
2008-01-07 17:40:43 +00:00
fclose($fp);
2008-02-12 16:39:59 +00:00
include $alias . '/b/c.php';
include $alias . '/b/new.php';
2008-01-07 17:40:43 +00:00
?>
===DONE===
--CLEAN--
2008-02-12 16:39:59 +00:00
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
2008-01-07 17:40:43 +00:00
--EXPECT--
This is b/c
extra
===DONE===