fopen_variation14.phpt 4.1 KB

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