1--TEST--
2Phar: fopen a .phar for writing (new file)
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.readonly=1
9phar.require_hash=0
10--FILE--
11<?php
12$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
13$pname = 'phar://' . $fname;
14$file = "<?php __HALT_COMPILER(); ?>";
15
16$files = array();
17$files['a.php'] = '<?php echo "This is a\n"; ?>';
18$files['b.php'] = '<?php echo "This is b\n"; ?>';
19$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
20include 'files/phar_test.inc';
21
22$fp = fopen($pname . '/b/new.php', 'wb');
23fwrite($fp, 'extra');
24fclose($fp);
25include $pname . '/b/c.php';
26include $pname . '/b/new.php';
27?>
28
29===DONE===
30--CLEAN--
31<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
32--EXPECTF--
33Warning: fopen(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c.php on line %d
34
35Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
36
37Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
38This is b/c
39
40Warning: include(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.php" in %sopen_for_write_newfile_c.php on line %d
41
42Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
43
44===DONE===
45