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