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