1--TEST--
2Bug#48746 - Junction not working properly
3
4--CREDIT--
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$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out);
14if (strpos($ret, 'privilege')) {
15	die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
16}
17unlink('bug48746_tmp.lnk');
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\" ?>");
34file_put_contents("$fullpath\\mnt\\test\\directory\\b.php", "<?php echo \"I am included.\n\" ?>");
35print_r(scandir("mklink_junction"));
36print_r(scandir("$fullpath\\mnt\\test\\directory"));
37print_r(scandir("$fullpath\\mnt\\test\\mklink_junction"));
38unlink("$fullpath\\mnt\\test\\directory\\b.php");
39unlink("mklink_junction\\a.php");
40chdir($old_dir);
41rmdir(__DIR__ . "\\mnt\\test\\directory");
42rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
43rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
44rmdir(__DIR__ . "\\mnt\\test");
45rmdir(__DIR__ . "\\mnt");
46
47?>
48--EXPECT--
49Array
50(
51    [0] => .
52    [1] => ..
53    [2] => a.php
54    [3] => b.php
55)
56Array
57(
58    [0] => .
59    [1] => ..
60    [2] => a.php
61    [3] => b.php
62)
63Array
64(
65    [0] => .
66    [1] => ..
67    [2] => a.php
68    [3] => b.php
69)
70