Annotation of embedaddon/php/ext/phar/tests/stat2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar: test stat function interceptions and is_file/is_link edge cases (PHP 5.2)
3: --SKIPIF--
4: <?php if (!extension_loaded("phar")) die("skip");?>
5: <?php if (substr(phpversion(), 0, 3) != '5.2') die("skip PHP 5.2 required for this test");?>
6: --INI--
7: phar.readonly=0
8: phar.require_hash=0
9: --FILE--
10: <?php
11: Phar::interceptFileFuncs();
12: is_file();
13: is_link();
14: var_dump(is_file(__FILE__));
15:
16: $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
17: $fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
18: copy(dirname(__FILE__) . '/tar/files/links.tar', $fname2);
19: $a = new PharData($fname2);
20: $b = $a->convertToExecutable();
21: unset($a);
22: Phar::unlinkArchive($fname2);
23: $b['foo/stat.php'] = '<?php
24: echo "is_link\n";
25: var_dump(is_link("./stat.php"),is_file("./stat.php"), is_link("./oops"), is_file("./oops"));
26: var_dump(is_link("testit/link"), filetype("testit/link"), filetype("testit"), is_file("testit/link"));
27: echo "not found\n";
28: var_dump(is_link("notfound"));
29: echo "dir\n";
30: var_dump(is_dir("./bar"), is_file("foo/bar/blah"));
31: ?>';
32: $b->addEmptyDir('foo/bar/blah');
33: $b->setStub('<?php
34: include "phar://" . __FILE__ . "/foo/stat.php";
35: __HALT_COMPILER();');
36: include $fname3;
37: ?>
38: ===DONE===
39: --CLEAN--
40: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
41: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
42: --EXPECTF--
43: Warning: Wrong parameter count for is_file() in %sstat2.php on line %d
44:
45: Warning: Wrong parameter count for is_link() in %sstat2.php on line %d
46: bool(true)
47: is_link
48: bool(false)
49: bool(true)
50: bool(false)
51: bool(false)
52: bool(true)
53: string(4) "link"
54: string(3) "dir"
55: bool(true)
56: not found
57: bool(false)
58: dir
59: bool(true)
60: bool(false)
61: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>