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