1--TEST--
2Test file() function : variation - various absolute and relative paths
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) != "WIN")
8  die("skip Only run on Windows");
9?>
10--FILE--
11<?php
12echo "*** Testing file() : variation ***\n";
13$mainDir = "fileVar8_win32.dir";
14$subDir = "fileVar8Sub";
15$absMainDir = __DIR__."\\".$mainDir;
16mkdir($absMainDir);
17$absSubDir = $absMainDir."\\".$subDir;
18mkdir($absSubDir);
19
20$old_dir_path = getcwd();
21chdir(__DIR__);
22$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
23
24$allDirs = array(
25  // absolute paths
26  "$absSubDir\\",
27  "$absSubDir\\..\\".$subDir,
28  "$absSubDir\\\\..\\.\\".$subDir,
29  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
30  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
31  "$absSubDir\\BADDIR",
32
33  // relative paths
34  $mainDir."\\".$subDir,
35  $mainDir."\\\\".$subDir,
36   $mainDir."\\\\\\".$subDir,
37  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
38  "BADDIR",
39
40  // unixifed path
41  $unixifiedDir,
42);
43
44$filename = 'FileGetContentsVar7.tmp';
45$absFile = $absSubDir.'/'.$filename;
46$h = fopen($absFile,"w");
47fwrite($h, "contents read");
48fclose($h);
49
50for($i = 0; $i<count($allDirs); $i++) {
51  $j = $i+1;
52  $dir = $allDirs[$i];
53  echo "\n-- Iteration $j --\n";
54  var_dump(file($dir."\\".$filename));
55}
56
57chdir($old_dir_path);
58
59echo "\n*** Done ***\n";
60?>
61--CLEAN--
62<?php
63$mainDir = "fileVar8_win32.dir";
64$subDir = "fileVar8Sub";
65$absMainDir = __DIR__."/".$mainDir;
66$absSubDir = $absMainDir."/".$subDir;
67$filename = 'FileGetContentsVar7.tmp';
68$absFile = $absSubDir.'/'.$filename;
69unlink($absFile);
70rmdir($absSubDir);
71rmdir($absMainDir);
72?>
73--EXPECTF--
74*** Testing file() : variation ***
75
76-- Iteration 1 --
77array(1) {
78  [0]=>
79  string(13) "contents read"
80}
81
82-- Iteration 2 --
83array(1) {
84  [0]=>
85  string(13) "contents read"
86}
87
88-- Iteration 3 --
89array(1) {
90  [0]=>
91  string(13) "contents read"
92}
93
94-- Iteration 4 --
95array(1) {
96  [0]=>
97  string(13) "contents read"
98}
99
100-- Iteration 5 --
101
102Warning: file(%sfileVar8_win32.dir\fileVar8Sub\..\\\fileVar8Sub\\..\\..\fileVar8Sub\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d
103bool(false)
104
105-- Iteration 6 --
106
107Warning: file(%sfileVar8_win32.dir\fileVar8Sub\BADDIR\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d
108bool(false)
109
110-- Iteration 7 --
111array(1) {
112  [0]=>
113  string(13) "contents read"
114}
115
116-- Iteration 8 --
117array(1) {
118  [0]=>
119  string(13) "contents read"
120}
121
122-- Iteration 9 --
123array(1) {
124  [0]=>
125  string(13) "contents read"
126}
127
128-- Iteration 10 --
129array(1) {
130  [0]=>
131  string(13) "contents read"
132}
133
134-- Iteration 11 --
135
136Warning: file(BADDIR\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d
137bool(false)
138
139-- Iteration 12 --
140array(1) {
141  [0]=>
142  string(13) "contents read"
143}
144
145*** Done ***
146