Annotation of embedaddon/php/ext/phar/tests/tar/refcount1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Phar: test that refcounting avoids problems with deleting a file tar-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: include dirname(__FILE__) . '/files/tarmaker.php.inc';
        !            13: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
        !            14: $alias = 'phar://' . $fname;
        !            15: 
        !            16: $tar = new tarmaker($fname, 'none');
        !            17: $tar->init();
        !            18: $tar->addFile('.phar/stub.php', "<?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: $files['.phar/alias.txt'] = 'hio';
        !            26: 
        !            27: foreach ($files as $n => $file) {
        !            28:        $tar->addFile($n, $file);
        !            29: }
        !            30: 
        !            31: $tar->close();
        !            32: 
        !            33: $fp = fopen($alias . '/b/c.php', 'wb');
        !            34: fwrite($fp, b"extra");
        !            35: fclose($fp);
        !            36: echo "===CLOSE===\n";
        !            37: $phar = new Phar($fname);
        !            38: $b = fopen($alias . '/b/c.php', 'rb');
        !            39: $a = $phar['b/c.php'];
        !            40: var_dump($a);
        !            41: var_dump(fread($b, 20));
        !            42: rewind($b);
        !            43: echo "===UNLINK===\n";
        !            44: unlink($alias . '/b/c.php');
        !            45: var_dump($a);
        !            46: var_dump(fread($b, 20));
        !            47: include $alias . '/b/c.php';
        !            48: 
        !            49: ?>
        !            50: 
        !            51: ===DONE===
        !            52: --CLEAN--
        !            53: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
        !            54: --EXPECTF--
        !            55: ===CLOSE===
        !            56: object(PharFileInfo)#%d (2) {
        !            57:   [%spathName":%sSplFileInfo":private]=>
        !            58:   string(%d) "phar://%srefcount1.phar.tar/b/c.php"
        !            59:   [%sfileName":%sSplFileInfo":private]=>
        !            60:   string(%d) "c.php"
        !            61: }
        !            62: string(5) "extra"
        !            63: ===UNLINK===
        !            64: 
        !            65: Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.tar", has open file pointers, cannot unlink in %srefcount1.php on line %d
        !            66: object(PharFileInfo)#%d (2) {
        !            67:   [%spathName":%sSplFileInfo":private]=>
        !            68:   string(%d) "phar://%srefcount1.phar.tar/b/c.php"
        !            69:   [%sfileName":%sSplFileInfo":private]=>
        !            70:   string(%s) "c.php"
        !            71: }
        !            72: string(5) "extra"
        !            73: extra
        !            74: ===DONE===

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