1--TEST--
2Test fopen() function : variation: file uri, use include path = true
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) != "WIN")
8  die("skip Run only on Windows");
9?>
10--FILE--
11<?php
12echo "*** Testing fopen() : variation ***\n";
13
14// fopen with interesting windows paths.
15$includePathDir = getcwd().'/fopen15.includeDir';
16$testDir = 'fopen15.tmpDir';
17$absTestDir = getcwd().'/'.$testDir;
18$file = "fopen_variation15.tmp";
19$unixifiedDir = '/'.substr(str_replace('\\','/',$absTestDir),3);
20$absFile = $absTestDir.'/'.$file;
21
22mkdir($testDir);
23mkdir($includePathDir);
24set_include_path($includePathDir);
25
26$files = array("file://$testDir\\$file",
27               "file://$testDir/$file",
28               "file://./$testDir/$file",
29               "file://.\\$testDir\\$file",
30               "file://$absTestDir/$file",
31               "file://$absTestDir\\$file",
32               "file://$unixifiedDir/$file"
33);
34
35runtest($files);
36
37chdir($testDir);
38$files = array("file://../$testDir/$file",
39               "file://..\\$testDir\\$file",
40               "file://$absTestDir/$file",
41               "file://$absTestDir\\$file",
42               "file://$unixifiedDir/$file"
43);
44runtest($files);
45chdir("..");
46rmdir($testDir);
47rmdir($includePathDir);
48
49function runtest($fileURIs) {
50   global $absFile;
51   $iteration = 0;
52   foreach($fileURIs as $fileURI) {
53      echo "--- READ: $fileURI ---\n";
54
55      $readData = "read:$iteration";
56      $writeData = "write:$iteration";
57
58      // create the file and test read
59      $h = fopen($absFile, 'w');
60      fwrite($h, $readData);
61      fclose($h);
62
63      $h = fopen($fileURI, 'r', true);
64      if ($h !== false) {
65         if (fread($h, 4096) != $readData) {
66            echo "contents not correct\n";
67         }
68         else {
69            echo "test passed\n";
70         }
71         fclose($h);
72      }
73      unlink($absFile);
74
75      echo "--- WRITE: $fileURI ---\n";
76      // create the file to test write
77      $h = fopen($fileURI, 'w', true);
78      if ($h !== false) {
79          fwrite($h, $writeData);
80          fclose($h);
81
82          $h = fopen($absFile, 'r');
83          if ($h !== false) {
84             if (fread($h, 4096) != $writeData) {
85                echo "contents not correct\n";
86             }
87             else {
88                echo "test passed\n";
89             }
90             fclose($h);
91          }
92          unlink($absFile);
93       }
94   }
95}
96
97
98?>
99--EXPECTF--
100*** Testing fopen() : variation ***
101--- READ: file://fopen15.tmpDir\fopen_variation15.tmp ---
102
103Warning: fopen(): Remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
104
105Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
106--- WRITE: file://fopen15.tmpDir\fopen_variation15.tmp ---
107
108Warning: fopen(): Remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
109
110Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
111--- READ: file://fopen15.tmpDir/fopen_variation15.tmp ---
112
113Warning: fopen(): Remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
114
115Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
116--- WRITE: file://fopen15.tmpDir/fopen_variation15.tmp ---
117
118Warning: fopen(): Remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
119
120Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
121--- READ: file://./fopen15.tmpDir/fopen_variation15.tmp ---
122
123Warning: fopen(): Remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
124
125Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
126--- WRITE: file://./fopen15.tmpDir/fopen_variation15.tmp ---
127
128Warning: fopen(): Remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
129
130Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
131--- READ: file://.\fopen15.tmpDir\fopen_variation15.tmp ---
132
133Warning: fopen(): Remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
134
135Warning: fopen(file://.\fopen15.tmpDir\fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
136--- WRITE: file://.\fopen15.tmpDir\fopen_variation15.tmp ---
137
138Warning: fopen(): Remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
139
140Warning: fopen(file://.\fopen15.tmpDir\fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
141--- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
142test passed
143--- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
144test passed
145--- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
146test passed
147--- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
148test passed
149--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
150test passed
151--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
152test passed
153--- READ: file://../fopen15.tmpDir/fopen_variation15.tmp ---
154
155Warning: fopen(): Remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
156
157Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
158--- WRITE: file://../fopen15.tmpDir/fopen_variation15.tmp ---
159
160Warning: fopen(): Remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
161
162Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
163--- READ: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
164
165Warning: fopen(): Remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
166
167Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
168--- WRITE: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
169
170Warning: fopen(): Remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
171
172Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
173--- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
174test passed
175--- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
176test passed
177--- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
178test passed
179--- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
180test passed
181--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
182test passed
183--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
184test passed
185