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

1.1       misho       1: --TEST--
                      2: Phar: test that refcounting avoids problems with deleting a file zip-based
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded("phar")) die("skip"); ?>
                      5: <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
                      6: <?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later"); ?>
                      7: --INI--
                      8: phar.readonly=0
                      9: phar.require_hash=0
                     10: --FILE--
                     11: <?php
                     12: 
                     13: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
                     14: $alias = 'phar://' . $fname;
                     15: 
                     16: $phar = new Phar($fname);
                     17: $phar->setStub("<?php __HALT_COMPILER(); ?>");
                     18: $phar->setAlias('hio');
                     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: $fp = fopen($alias . '/b/c.php', 'wb');
                     32: fwrite($fp, b"extra");
                     33: fclose($fp);
                     34: echo "===CLOSE===\n";
                     35: $b = fopen($alias . '/b/c.php', 'rb');
                     36: $a = $phar['b/c.php'];
                     37: var_dump($a);
                     38: var_dump(fread($b, 20));
                     39: rewind($b);
                     40: echo "===UNLINK===\n";
                     41: unlink($alias . '/b/c.php');
                     42: var_dump($a);
                     43: var_dump(fread($b, 20));
                     44: include $alias . '/b/c.php';
                     45: ?>
                     46: 
                     47: ===DONE===
                     48: --CLEAN--
                     49: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
                     50: --EXPECTF--
                     51: ===CLOSE===
                     52: object(PharFileInfo)#%d (2) {
                     53:   [%spathName":%sSplFileInfo":private]=>
                     54:   string(%d) "phar://%srefcount1.phar.zip/b/c.php"
                     55:   [%sfileName":%sSplFileInfo":private]=>
                     56:   string(%d) "c.php"
                     57: }
                     58: string(5) "extra"
                     59: ===UNLINK===
                     60: 
                     61: Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.zip", has open file pointers, cannot unlink in %srefcount1.php on line %d
                     62: object(PharFileInfo)#%d (2) {
                     63:   [%spathName":%sSplFileInfo":private]=>
                     64:   string(%d) "phar://%srefcount1.phar.zip/b/c.php"
                     65:   [%sfileName":%sSplFileInfo":private]=>
                     66:   string(%s) "c.php"
                     67: }
                     68: string(5) "extra"
                     69: extra
                     70: ===DONE===

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