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