Annotation of embedaddon/php/ext/phar/tests/tar/tar_003.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar: tar-based phar, valid 1
3: --SKIPIF--
4: <?php if (!extension_loaded('phar')) die('skip'); ?>
5: <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
6: --INI--
7: phar.readonly=0
8: phar.require_hash=0
9: --FILE--
10: <?php
11: include dirname(__FILE__) . '/files/tarmaker.php.inc';
12:
13: $fname = dirname(__FILE__) . '/tar_003.phar.tar';
14: $alias = 'phar://' . $fname;
15:
16: $tar = new tarmaker($fname, 'none');
17: $tar->init();
18: $tar->addFile('.phar/stub.php', "<?php // tar-based phar archive stub file\n__HALT_COMPILER();");
19: $tar->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r'));
20: $tar->addFile('internal/file/here', "hi there!\n");
21: $tar->mkDir('internal/dir');
22: $tar->mkDir('dir');
23: $tar->close();
24:
25: fclose($g);
26:
27: echo file_get_contents($alias . '/internal/file/here');
28:
29: try {
30: $tar = opendir($alias . '/');
31: } catch (Exception $e) {
32: echo $e->getMessage()."\n";
33: }
34:
35: while (false !== ($v = readdir($tar))) {
36: echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n");
37: echo $v . "\n";
38: }
39: closedir($tar);
40:
41: /* ensure none of the dir tar files were freed */
42: echo "second round\n";
43: $tar = opendir($alias . '/');
44: while (false !== ($v = readdir($tar))) {
45: echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n");
46: echo $v . "\n";
47: }
48: closedir($tar);
49:
50: ?>
51: ===DONE===
52: --CLEAN--
53: <?php
54: @unlink(dirname(__FILE__) . '/tar_003.phar.tar');
55: ?>
56: --EXPECT--
57: hi there!
58: dir
59: dir
60: dir
61: internal
62: file
63: tar_003.phpt
64: second round
65: dir
66: dir
67: dir
68: internal
69: file
70: tar_003.phpt
71: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>