1--TEST--
2file() with various paths
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip non-windows only test');
7}
8?>
9--FILE--
10<?php
11
12$script_directory = __DIR__;
13chdir($script_directory);
14$test_dirname = basename(__FILE__, ".php") . "testdir";
15mkdir($test_dirname);
16
17$filepath = __DIR__ . '/file_variation_5.tmp';
18$filename = basename($filepath);
19$fd = fopen($filepath, "w+");
20fwrite($fd, "Line 1\nLine 2\nLine 3");
21fclose($fd);
22
23echo "file() on a path containing .. and .\n";
24var_dump(file("./$test_dirname/../$filename"));
25
26echo "\nfile() on a path containing .. with invalid directories\n";
27var_dump(file("./$test_dirname/bad_dir/../../$filename"));
28
29echo "\nfile() on a linked file\n";
30$linkname = "somelink";
31var_dump(symlink($filepath, $linkname));
32var_dump(file($linkname));
33var_dump(unlink($linkname));
34
35echo "\nfile() on a relative path from a different working directory\n";
36chdir($test_dirname);
37var_dump(file("../$filename"));
38chdir($script_directory);
39
40?>
41--CLEAN--
42<?php
43$test_dirname = __DIR__ . '/' . basename(__FILE__, ".clean.php") . "testdir";
44$filepath = __DIR__ . '/file_variation_5.tmp';
45@unlink($filepath); // Should be delete via the symlink deletion
46rmdir($test_dirname);
47?>
48--EXPECT--
49file() on a path containing .. and .
50array(3) {
51  [0]=>
52  string(7) "Line 1
53"
54  [1]=>
55  string(7) "Line 2
56"
57  [2]=>
58  string(6) "Line 3"
59}
60
61file() on a path containing .. with invalid directories
62array(3) {
63  [0]=>
64  string(7) "Line 1
65"
66  [1]=>
67  string(7) "Line 2
68"
69  [2]=>
70  string(6) "Line 3"
71}
72
73file() on a linked file
74bool(true)
75array(3) {
76  [0]=>
77  string(7) "Line 1
78"
79  [1]=>
80  string(7) "Line 2
81"
82  [2]=>
83  string(6) "Line 3"
84}
85bool(true)
86
87file() on a relative path from a different working directory
88array(3) {
89  [0]=>
90  string(7) "Line 1
91"
92  [1]=>
93  string(7) "Line 2
94"
95  [2]=>
96  string(6) "Line 3"
97}
98