Annotation of embedaddon/php/ext/standard/tests/file/fopen_variation15.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fopen() function : variation: file uri, use include path = true
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --SKIPIF--
6: <?php
7: if(substr(PHP_OS, 0, 3) == "WIN")
8: die("skip Not for Windows");
9: ?>
10: --FILE--
11: <?php
12: /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
13: * Description: Open a file or a URL and return a file pointer
14: * Source code: ext/standard/file.c
15: * Alias to functions:
16: */
17:
18: echo "*** Testing fopen() : variation ***\n";
19:
20: // fopen with interesting windows paths.
21: $includePathDir = getcwd().'/fopen15.includeDir';
22: $testDir = 'fopen15.tmpDir';
23: $absTestDir = getcwd().'/'.$testDir;
24: $file = "fopen_variation15.tmp";
25: $absFile = $absTestDir.'/'.$file;
26:
27: mkdir($testDir);
28: mkdir($includePathDir);
29: set_include_path($includePathDir);
30:
31: $files = array("file://$testDir/$file",
32: "file://./$testDir/$file",
33: "file://$absTestDir/$file"
34: );
35:
36: runtest($files);
37:
38: chdir($testDir);
39: $files = array("file://../$testDir/$file",
40: "file://$absTestDir/$file"
41: );
42: runtest($files);
43: chdir("..");
44: rmdir($testDir);
45: rmdir($includePathDir);
46:
47: function runtest($fileURIs) {
48: global $absFile;
49: $iteration = 0;
50: foreach($fileURIs as $fileURI) {
51: echo "--- READ: $fileURI ---\n";
52:
53: $readData = "read:$iteration";
54: $writeData = "write:$iteration";
55:
56: // create the file and test read
57: $h = fopen($absFile, 'w');
58: fwrite($h, $readData);
59: fclose($h);
60:
61: $h = fopen($fileURI, 'r', true);
62: if ($h !== false) {
63: if (fread($h, 4096) != $readData) {
64: echo "contents not correct\n";
65: }
66: else {
67: echo "test passed\n";
68: }
69: fclose($h);
70: }
71: unlink($absFile);
72:
73: echo "--- WRITE: $fileURI ---\n";
74: // create the file to test write
75: $h = fopen($fileURI, 'w', true);
76: if ($h !== false) {
77: fwrite($h, $writeData);
78: fclose($h);
79:
80: $h = fopen($absFile, 'r');
81: if ($h !== false) {
82: if (fread($h, 4096) != $writeData) {
83: echo "contents not correct\n";
84: }
85: else {
86: echo "test passed\n";
87: }
88: fclose($h);
89: }
90: unlink($absFile);
91: }
92: }
93: }
94:
95:
96: ?>
97: ===DONE===
98: --EXPECTF--
99: *** Testing fopen() : variation ***
100: --- READ: file://fopen15.tmpDir/fopen_variation15.tmp ---
101:
102: Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
103:
104: Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
105: --- WRITE: file://fopen15.tmpDir/fopen_variation15.tmp ---
106:
107: Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
108:
109: Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
110: --- READ: file://./fopen15.tmpDir/fopen_variation15.tmp ---
111:
112: Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
113:
114: Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
115: --- WRITE: file://./fopen15.tmpDir/fopen_variation15.tmp ---
116:
117: Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
118:
119: Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
120: --- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
121: test passed
122: --- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
123: test passed
124: --- READ: file://../fopen15.tmpDir/fopen_variation15.tmp ---
125:
126: Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
127:
128: Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
129: --- WRITE: file://../fopen15.tmpDir/fopen_variation15.tmp ---
130:
131: Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
132:
133: Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
134: --- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
135: test passed
136: --- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
137: test passed
138: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>