1--TEST--
2Bug#48746 - Junction not working properly
3
4--CREDITS--
5Venkat Raman Don (don.raman@microsoft.com)
6
7--SKIPIF--
8<?php
9if(substr(PHP_OS, 0, 3) != 'WIN' ) {
10    die('skip windows only test');
11}
12include_once __DIR__ . '/common.inc';
13$cmd = "mklink /?";
14$ret = @exec($cmd, $output, $return_val);
15if (count($output) == 0) {
16    die("mklink.exe not found in PATH");
17}
18?>
19--FILE--
20<?php
21include_once __DIR__ . '/common.inc';
22$mountvol = get_mountvol();
23$old_dir = __DIR__;
24$dirname = __DIR__ . "\\mnt\\test\\directory";
25exec("mkdir " . $dirname, $output, $ret_val);
26chdir(__DIR__ . "\\mnt\\test");
27$drive = substr(__DIR__, 0, 2);
28$pathwithoutdrive = substr(__DIR__, 2);
29$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
30exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
31$fullpath = "mounted_volume" . $pathwithoutdrive;
32exec("mklink /j mklink_junction directory", $output, $ret_val);
33file_put_contents("mklink_junction\\a.php", "<?php echo \"I am included.\n\" ?>");
34include_once "mklink_junction\\a.php";
35file_put_contents("$fullpath\\mnt\\test\\directory\\b.php", "<?php echo \"I am included.\n\" ?>");
36require "$fullpath\\mnt\\test\\directory\\b.php";
37file_put_contents("$fullpath\\mnt\\test\\mklink_junction\\c.php", "<?php echo \"I am included.\n\" ?>");
38require_once "$fullpath\\mnt\\test\\mklink_junction\\c.php";
39var_dump(is_file("mklink_junction\\a.php"));
40var_dump(is_file("$fullpath\\mnt\\test\\directory\\b.php"));
41var_dump(is_file("$fullpath\\mnt\\test\\mklink_junction\\c.php"));
42unlink("$fullpath\\mnt\\test\\directory\\b.php");
43unlink("$fullpath\\mnt\\test\\mklink_junction\\c.php");
44unlink("mklink_junction\\a.php");
45chdir($old_dir);
46rmdir(__DIR__ . "\\mnt\\test\\directory");
47rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
48rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
49rmdir(__DIR__ . "\\mnt\\test");
50rmdir(__DIR__ . "\\mnt");
51
52?>
53--EXPECT--
54I am included.
55I am included.
56I am included.
57bool(true)
58bool(true)
59bool(true)
60