fopen_variation14-win32.phpt 7.1 KB

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