Annotation of embedaddon/php/ext/phar/tests/zip/open_for_write_existing_b.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Phar: fopen a .phar for writing (existing file) zip-based
                      3: --SKIPIF--
                      4: <?php
                      5: if (!extension_loaded("phar")) die("skip");
                      6: if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
                      7: ?>
                      8: --INI--
                      9: phar.readonly=0
                     10: phar.require_hash=0
                     11: --FILE--
                     12: <?php
                     13: 
                     14: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
                     15: $alias = 'phar://' . $fname;
                     16: 
                     17: $phar = new Phar($fname);
                     18: $phar->setStub('<?php __HALT_COMPILER(); ?>');
                     19: 
                     20: $files = array();
                     21: 
                     22: $files['a.php'] = '<?php echo "This is a\n"; ?>';
                     23: $files['b.php'] = '<?php echo "This is b\n"; ?>';
                     24: $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
                     25: 
                     26: foreach ($files as $n => $file) {
                     27:        $phar[$n] = $file;
                     28: }
                     29: $phar->stopBuffering();
                     30: 
                     31: ini_set('phar.readonly', 1);
                     32: 
                     33: function err_handler($errno, $errstr, $errfile, $errline) {
                     34:   echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
                     35: }
                     36: 
                     37: set_error_handler("err_handler", E_RECOVERABLE_ERROR);
                     38: 
                     39: $fp = fopen($alias . '/b/c.php', 'wb');
                     40: fwrite($fp, b'extra');
                     41: fclose($fp);
                     42: include $alias . '/b/c.php';
                     43: ?>
                     44: ===DONE===
                     45: --CLEAN--
                     46: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
                     47: --EXPECTF--
                     48: 
                     49: Warning: fopen(phar://%sopen_for_write_existing_b.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b.php on line %d
                     50: 
                     51: Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_b.php on line %d
                     52: 
                     53: Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_b.php on line %d
                     54: This is b/c
                     55: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>