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