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 not for 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$absFile = $absTestDir.'/'.$file; 19 20mkdir($testDir); 21 22$files = array("file://$testDir/$file", 23 "file://./$testDir/$file", 24 "file://$absTestDir/$file" 25); 26 27runtest($files); 28 29chdir($testDir); 30$files = array("file://../$testDir/$file", 31 "file://$absTestDir/$file", 32); 33runtest($files); 34chdir(".."); 35rmdir($testDir); 36 37function runtest($fileURIs) { 38 global $absFile; 39 $iteration = 0; 40 foreach($fileURIs as $fileURI) { 41 echo "--- READ: $fileURI ---\n"; 42 43 $readData = "read:$iteration"; 44 $writeData = "write:$iteration"; 45 46 // create the file and test read 47 $h = fopen($absFile, 'w'); 48 fwrite($h, $readData); 49 fclose($h); 50 51 $h = fopen($fileURI, 'r'); 52 if ($h !== false) { 53 if (fread($h, 4096) != $readData) { 54 echo "contents not correct\n"; 55 } 56 else { 57 echo "test passed\n"; 58 } 59 fclose($h); 60 } 61 unlink($absFile); 62 63 echo "--- WRITE: $fileURI ---\n"; 64 // create the file to test write 65 $h = fopen($fileURI, 'w'); 66 if ($h !== false) { 67 fwrite($h, $writeData); 68 fclose($h); 69 70 $h = fopen($absFile, 'r'); 71 if ($h !== false) { 72 if (fread($h, 4096) != $writeData) { 73 echo "contents not correct\n"; 74 } 75 else { 76 echo "test passed\n"; 77 } 78 fclose($h); 79 } 80 unlink($absFile); 81 } 82 } 83} 84 85 86?> 87--EXPECTF-- 88*** Testing fopen() : variation *** 89--- READ: file://fopen14.tmpDir/fopen_variation14.tmp --- 90 91Warning: fopen(): Remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d 92 93Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d 94--- WRITE: file://fopen14.tmpDir/fopen_variation14.tmp --- 95 96Warning: fopen(): Remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d 97 98Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d 99--- READ: file://./fopen14.tmpDir/fopen_variation14.tmp --- 100 101Warning: fopen(): Remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d 102 103Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d 104--- WRITE: file://./fopen14.tmpDir/fopen_variation14.tmp --- 105 106Warning: fopen(): Remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d 107 108Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d 109--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp --- 110test passed 111--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp --- 112test passed 113--- READ: file://../fopen14.tmpDir/fopen_variation14.tmp --- 114 115Warning: fopen(): Remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d 116 117Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d 118--- WRITE: file://../fopen14.tmpDir/fopen_variation14.tmp --- 119 120Warning: fopen(): Remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d 121 122Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d 123--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp --- 124test passed 125--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp --- 126test passed 127