fopen_variation15-win32.phpt 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 Run only on 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. echo "*** Testing fopen() : variation ***\n";
  18. // fopen with interesting windows paths.
  19. $includePathDir = getcwd().'/fopen15.includeDir';
  20. $testDir = 'fopen15.tmpDir';
  21. $absTestDir = getcwd().'/'.$testDir;
  22. $file = "fopen_variation15.tmp";
  23. $unixifiedDir = '/'.substr(str_replace('\\','/',$absTestDir),3);
  24. $absFile = $absTestDir.'/'.$file;
  25. mkdir($testDir);
  26. mkdir($includePathDir);
  27. set_include_path($includePathDir);
  28. $files = array("file://$testDir\\$file",
  29. "file://$testDir/$file",
  30. "file://./$testDir/$file",
  31. "file://.\\$testDir\\$file",
  32. "file://$absTestDir/$file",
  33. "file://$absTestDir\\$file",
  34. "file://$unixifiedDir/$file"
  35. );
  36. runtest($files);
  37. chdir($testDir);
  38. $files = array("file://../$testDir/$file",
  39. "file://..\\$testDir\\$file",
  40. "file://$absTestDir/$file",
  41. "file://$absTestDir\\$file",
  42. "file://$unixifiedDir/$file"
  43. );
  44. runtest($files);
  45. chdir("..");
  46. rmdir($testDir);
  47. rmdir($includePathDir);
  48. function runtest($fileURIs) {
  49. global $absFile;
  50. $iteration = 0;
  51. foreach($fileURIs as $fileURI) {
  52. echo "--- READ: $fileURI ---\n";
  53. $readData = "read:$iteration";
  54. $writeData = "write:$iteration";
  55. // create the file and test read
  56. $h = fopen($absFile, 'w');
  57. fwrite($h, $readData);
  58. fclose($h);
  59. $h = fopen($fileURI, 'r', true);
  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. echo "--- WRITE: $fileURI ---\n";
  71. // create the file to test write
  72. $h = fopen($fileURI, 'w', true);
  73. if ($h !== false) {
  74. fwrite($h, $writeData);
  75. fclose($h);
  76. $h = fopen($absFile, 'r');
  77. if ($h !== false) {
  78. if (fread($h, 4096) != $writeData) {
  79. echo "contents not correct\n";
  80. }
  81. else {
  82. echo "test passed\n";
  83. }
  84. fclose($h);
  85. }
  86. unlink($absFile);
  87. }
  88. }
  89. }
  90. ?>
  91. ===DONE===
  92. --EXPECTF--
  93. *** Testing fopen() : variation ***
  94. --- READ: file://fopen15.tmpDir\fopen_variation15.tmp ---
  95. Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
  96. Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  97. --- WRITE: file://fopen15.tmpDir\fopen_variation15.tmp ---
  98. Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
  99. Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  100. --- READ: file://fopen15.tmpDir/fopen_variation15.tmp ---
  101. Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
  102. Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  103. --- WRITE: file://fopen15.tmpDir/fopen_variation15.tmp ---
  104. Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
  105. Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  106. --- READ: file://./fopen15.tmpDir/fopen_variation15.tmp ---
  107. Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
  108. Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  109. --- WRITE: file://./fopen15.tmpDir/fopen_variation15.tmp ---
  110. Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
  111. Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  112. --- READ: file://.\fopen15.tmpDir\fopen_variation15.tmp ---
  113. Warning: fopen(): remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
  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. Warning: fopen(): remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
  117. Warning: fopen(file://.\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  118. --- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
  119. test passed
  120. --- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
  121. test passed
  122. --- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
  123. test passed
  124. --- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
  125. test passed
  126. --- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
  127. test passed
  128. --- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
  129. test passed
  130. --- READ: file://../fopen15.tmpDir/fopen_variation15.tmp ---
  131. Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
  132. Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  133. --- WRITE: file://../fopen15.tmpDir/fopen_variation15.tmp ---
  134. Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
  135. Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  136. --- READ: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
  137. Warning: fopen(): remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
  138. Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  139. --- WRITE: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
  140. Warning: fopen(): remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
  141. Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
  142. --- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
  143. test passed
  144. --- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
  145. test passed
  146. --- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
  147. test passed
  148. --- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
  149. test passed
  150. --- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
  151. test passed
  152. --- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
  153. test passed
  154. ===DONE===