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$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";
25mkdir($dirname, 0700, true);
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);
33var_dump(file_exists("directory"));
34var_dump(file_exists("mklink_junction"));
35var_dump(file_exists("mounted_volume"));
36var_dump(file_exists("$fullpath"));
37var_dump(is_dir("mklink_junction"));
38var_dump(is_dir("$fullpath"));
39var_dump(is_readable("mklink_junction"));
40var_dump(is_writeable("$fullpath"));
41chdir($old_dir);
42
43rmdir(__DIR__ . "\\mnt\\test\\directory");
44rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
45rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
46rmdir(__DIR__ . "\\mnt\\test");
47rmdir(__DIR__ . "\\mnt");
48
49?>
50--EXPECT--
51bool(true)
52bool(true)
53bool(true)
54bool(true)
55bool(true)
56bool(true)
57bool(true)
58bool(true)
59