Annotation of embedaddon/php/ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar: fopen a .phar for writing (new file) tar-based
3: --SKIPIF--
4: <?php if (!extension_loaded("phar")) die("skip"); ?>
5: <?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
6: --INI--
7: phar.readonly=0
8: phar.require_hash=0
9: --FILE--
10: <?php
11:
12: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
13: $alias = 'phar://' . $fname;
14:
15: $phar = new Phar($fname);
16: $phar->setStub("<?php __HALT_COMPILER(); ?>");
17:
18: $files = array();
19:
20: $files['a.php'] = '<?php echo "This is a\n"; ?>';
21: $files['b.php'] = '<?php echo "This is b\n"; ?>';
22: $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
23:
24: foreach ($files as $n => $file) {
25: $phar[$n] = $file;
26: }
27:
28: $phar->stopBuffering();
29: ini_set('phar.readonly', 1);
30:
31: function err_handler($errno, $errstr, $errfile, $errline) {
32: echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
33: }
34:
35: set_error_handler("err_handler", E_RECOVERABLE_ERROR);
36:
37: $fp = fopen($alias . '/b/new.php', 'wb');
38: fwrite($fp, b'extra');
39: fclose($fp);
40:
41: include $alias . '/b/c.php';
42: include $alias . '/b/new.php';
43:
44: ?>
45:
46: ===DONE===
47: --CLEAN--
48: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
49: --EXPECTF--
50:
51: Warning: fopen(phar://%sopen_for_write_newfile_b_5_2.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_b_5_2.php on line %d
52:
53: Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
54:
55: Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
56: This is b/c
57:
58: Warning: include(phar://%sopen_for_write_newfile_b_5_2.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b_5_2.phar.tar" in %sopen_for_write_newfile_b_5_2.php on line %d
59:
60: Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b_5_2.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b_5_2.php on line %d
61:
62: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>