xref: /php-src/ext/phar/tests/stat2_5.3.phpt (revision 98d004c9)
1--TEST--
2Phar: test stat function interceptions and is_file/is_link edge cases (PHP 5.3+)
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10Phar::interceptFileFuncs();
11var_dump(is_file(__FILE__));
12
13$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar';
14$fname3 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar';
15copy(__DIR__ . '/tar/files/links.tar', $fname2);
16$a = new PharData($fname2);
17$b = $a->convertToExecutable(Phar::TAR, Phar::NONE, '.phar.tar');
18unset($a);
19Phar::unlinkArchive($fname2);
20$b['foo/stat.php'] = '<?php
21echo "is_link\n";
22var_dump(is_link("./stat.php"),is_file("./stat.php"), is_link("./oops"), is_file("./oops"));
23var_dump(is_link("testit/link"), filetype("testit/link"), filetype("testit"), is_file("testit/link"));
24echo "not found\n";
25var_dump(is_link("notfound"));
26echo "dir\n";
27var_dump(is_dir("./bar"), is_file("foo/bar/blah"));
28?>';
29$b->addEmptyDir('foo/bar/blah');
30$b->setStub('<?php
31include "phar://" . __FILE__ . "/foo/stat.php";
32__HALT_COMPILER();');
33include $fname3;
34?>
35--CLEAN--
36<?php
37unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
38@unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar');
39?>
40--EXPECT--
41bool(true)
42is_link
43bool(false)
44bool(true)
45bool(false)
46bool(false)
47bool(true)
48string(4) "link"
49string(3) "dir"
50bool(true)
51not found
52bool(false)
53dir
54bool(true)
55bool(false)
56