fopen_variation14-win32.phpt 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. echo "*** Testing fopen() : variation ***\n";
  13. // fopen with interesting windows paths.
  14. $testDir = 'fopen14.tmpDir';
  15. $absTestDir = getcwd().'/'.$testDir;
  16. $file = "fopen_variation14.tmp";
  17. $unixifiedDir = '/'.substr(str_replace('\\','/',$absTestDir),3);
  18. $absFile = $absTestDir.'/'.$file;
  19. mkdir($testDir);
  20. $files = array("file://$testDir\\$file",
  21. "file://$testDir/$file",
  22. "file://./$testDir/$file",
  23. "file://.\\$testDir\\$file",
  24. "file://$absTestDir/$file",
  25. "file://$absTestDir\\$file",
  26. "file://$unixifiedDir/$file"
  27. );
  28. runtest($files);
  29. chdir($testDir);
  30. $files = array("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("..");
  38. rmdir($testDir);
  39. function runtest($fileURIs) {
  40. global $absFile;
  41. $iteration = 0;
  42. foreach($fileURIs as $fileURI) {
  43. echo "--- READ: $fileURI ---\n";
  44. $readData = "read:$iteration";
  45. $writeData = "write:$iteration";
  46. // create the file and test read
  47. $h = fopen($absFile, 'w');
  48. fwrite($h, $readData);
  49. fclose($h);
  50. $h = fopen($fileURI, 'r');
  51. if ($h !== false) {
  52. if (fread($h, 4096) != $readData) {
  53. echo "contents not correct\n";
  54. }
  55. else {
  56. echo "test passed\n";
  57. }
  58. fclose($h);
  59. }
  60. unlink($absFile);
  61. echo "--- WRITE: $fileURI ---\n";
  62. // create the file to test write
  63. $h = fopen($fileURI, 'w');
  64. if ($h !== false) {
  65. fwrite($h, $writeData);
  66. fclose($h);
  67. $h = fopen($absFile, 'r');
  68. if ($h !== false) {
  69. if (fread($h, 4096) != $writeData) {
  70. echo "contents not correct\n";
  71. }
  72. else {
  73. echo "test passed\n";
  74. }
  75. fclose($h);
  76. }
  77. unlink($absFile);
  78. }
  79. }
  80. }
  81. ?>
  82. --EXPECTF--
  83. *** Testing fopen() : variation ***
  84. --- READ: file://fopen14.tmpDir\fopen_variation14.tmp ---
  85. Warning: fopen(): Remote host file access not supported, file://fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
  86. Warning: fopen(file://fopen14.tmpDir\fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
  87. --- WRITE: file://fopen14.tmpDir\fopen_variation14.tmp ---
  88. Warning: fopen(): Remote host file access not supported, file://fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
  89. Warning: fopen(file://fopen14.tmpDir\fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
  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://%s/fopen14.tmpDir/fopen_variation14.tmp ---
  109. test passed
  110. --- WRITE: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
  111. test passed
  112. --- READ: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
  113. test passed
  114. --- WRITE: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
  115. test passed
  116. --- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
  117. test passed
  118. --- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
  119. test passed
  120. --- READ: file://../fopen14.tmpDir/fopen_variation14.tmp ---
  121. Warning: fopen(): Remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
  122. Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
  123. --- WRITE: file://../fopen14.tmpDir/fopen_variation14.tmp ---
  124. Warning: fopen(): Remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
  125. Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): Failed to open stream: no suitable wrapper could be found in %s on line %d
  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://%s/fopen14.tmpDir/fopen_variation14.tmp ---
  133. test passed
  134. --- WRITE: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
  135. test passed
  136. --- READ: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
  137. test passed
  138. --- WRITE: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
  139. test passed
  140. --- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
  141. test passed
  142. --- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
  143. test passed