xref: /PHP-7.3/ext/standard/tests/file/bug47767.phpt (revision d663296e)
1--TEST--
2bug #47767 (include_once does not resolve windows symlinks or junctions)
3--CREDITS--
4Venkat Raman Don
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) != 'WIN' ) {
8		die('skip windows only test');
9}
10if(PHP_WINDOWS_VERSION_MAJOR < 6)  {
11        die('skip windows version 6.0+ only test');
12}
13
14$fn = "bug47767.lnk";
15$ret = exec("mklink $fn " . __FILE__ .' 2>&1', $out);
16@unlink($fn);
17if (strpos($ret, 'privilege')) {
18	die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
19}
20?>
21--FILE--
22<?php
23echo "Testing include_once using file symbolic link\n";
24$filename = __DIR__ . '\\a.php';
25$content = '<?php echo "I am included\n" ?>';
26file_put_contents($filename, $content);
27$softlinkname = __DIR__ . '\\a_slink.php';
28symlink($filename, $softlinkname);
29include_once("$filename");
30include_once("$softlinkname");
31include_once("$softlinkname");
32
33echo "Testing include_once using directory symbolic link\n";
34$softdirlinkname = __DIR__ . "\\a_dir";
35symlink(__DIR__, $softdirlinkname);
36include_once("$softdirlinkname" . '\\a.php');
37
38echo "Testing include_once using junction points\n";
39$junctionname = __DIR__ . '\\a_jdir';
40exec("mklink /J $junctionname " . __DIR__);
41include_once("$junctionname" . '\\a.php');
42
43unlink($filename);
44unlink($softlinkname);
45rmdir($softdirlinkname);
46rmdir($junctionname);
47?>
48--EXPECT--
49Testing include_once using file symbolic link
50I am included
51Testing include_once using directory symbolic link
52Testing include_once using junction points
53