fopen_variation15-win32.phpt 7.0 KB

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