Annotation of embedaddon/php/ext/phar/tests/zip/refcount1_5_2.phpt, revision 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.2 or earlier"); ?>
! 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, "extra");
! 33: fclose($fp);
! 34:
! 35: echo "===CLOSE===\n";
! 36:
! 37: $b = fopen($alias . '/b/c.php', 'rb');
! 38: $a = $phar['b/c.php'];
! 39: var_dump($a);
! 40: var_dump(fread($b, 20));
! 41: rewind($b);
! 42: echo "===UNLINK===\n";
! 43: unlink($alias . '/b/c.php');
! 44: var_dump($a);
! 45: var_dump(fread($b, 20));
! 46: include $alias . '/b/c.php';
! 47: ?>
! 48:
! 49: ===DONE===
! 50: --CLEAN--
! 51: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
! 52: --EXPECTF--
! 53: ===CLOSE===
! 54: object(PharFileInfo)#%d (0) {
! 55: }
! 56: string(5) "extra"
! 57: ===UNLINK===
! 58:
! 59: Warning: unlink(): phar error: "b/c.php" in phar "%sefcount1_5_2.phar.zip", has open file pointers, cannot unlink in %sefcount1_5_2.php on line %d
! 60: object(PharFileInfo)#%d (0) {
! 61: }
! 62: string(5) "extra"
! 63: extra
! 64: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>