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