Annotation of embedaddon/php/ext/phar/tests/refcount1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar: test that refcounting avoids problems with deleting a file
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: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
13: $pname = 'phar://' . $fname;
14: $file = b"<?php __HALT_COMPILER(); ?>";
15:
16: $files = array();
17: $files['a.php'] = '<?php echo "This is a\n"; ?>';
18: $files['b.php'] = '<?php echo "This is b\n"; ?>';
19: $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
20: include 'files/phar_test.inc';
21:
22: $fp = fopen($pname . '/b/c.php', 'wb');
23: fwrite($fp, b"extra");
24: fclose($fp);
25: echo "===CLOSE===\n";
26: $p = new Phar($fname);
27: $b = fopen($pname . '/b/c.php', 'rb');
28: $a = $p['b/c.php'];
29: var_dump($a);
30: var_dump(fread($b, 20));
31: rewind($b);
32: echo "===UNLINK===\n";
33: unlink($pname . '/b/c.php');
34: var_dump($a);
35: var_dump(fread($b, 20));
36: include $pname . '/b/c.php';
37: ?>
38:
39: ===DONE===
40: --CLEAN--
41: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
42: --EXPECTF--
43: ===CLOSE===
44: object(PharFileInfo)#%d (2) {
45: [%spathName":%sSplFileInfo":private]=>
46: string(%d) "phar://%srefcount1.phar.php/b/c.php"
47: [%sfileName":%sSplFileInfo":private]=>
48: string(%d) "c.php"
49: }
50: string(5) "extra"
51: ===UNLINK===
52:
53: Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.php", has open file pointers, cannot unlink in %srefcount1.php on line %d
54: object(PharFileInfo)#%d (2) {
55: [%spathName":%sSplFileInfo":private]=>
56: string(%d) "phar://%srefcount1.phar.php/b/c.php"
57: [%sfileName":%sSplFileInfo":private]=>
58: string(%s) "c.php"
59: }
60: string(5) "extra"
61: extra
62: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>