1--TEST--
2file() with various paths
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') {
6    die('skip windows only test');
7}
8?>
9--FILE--
10<?php
11
12$script_directory = dirname(__FILE__);
13chdir($script_directory);
14$test_dirname = basename(__FILE__, ".php") . "私はガラスを食べられますtestdir";
15mkdir($test_dirname);
16
17$filepath = __FILE__ . ".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 relative path from a different working directory\n";
30chdir($test_dirname);
31var_dump(file("../$filename"));
32chdir($script_directory);
33
34chdir($script_directory);
35unlink($filepath);
36rmdir($test_dirname);
37
38?>
39--EXPECT--
40file() on a path containing .. and .
41array(3) {
42  [0]=>
43  string(7) "Line 1
44"
45  [1]=>
46  string(7) "Line 2
47"
48  [2]=>
49  string(6) "Line 3"
50}
51
52file() on a path containing .. with invalid directories
53array(3) {
54  [0]=>
55  string(7) "Line 1
56"
57  [1]=>
58  string(7) "Line 2
59"
60  [2]=>
61  string(6) "Line 3"
62}
63
64file() on a relative path from a different working directory
65array(3) {
66  [0]=>
67  string(7) "Line 1
68"
69  [1]=>
70  string(7) "Line 2
71"
72  [2]=>
73  string(6) "Line 3"
74}
75