file_variation8-win32.phpt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. --TEST--
  2. Test file() function : variation - various absolute and relative paths
  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 Only run on Windows");
  9. ?>
  10. --FILE--
  11. <?php
  12. echo "*** Testing file() : variation ***\n";
  13. $mainDir = "fileVar8.dir";
  14. $subDir = "fileVar8Sub";
  15. $absMainDir = __DIR__."\\".$mainDir;
  16. mkdir($absMainDir);
  17. $absSubDir = $absMainDir."\\".$subDir;
  18. mkdir($absSubDir);
  19. $old_dir_path = getcwd();
  20. chdir(__DIR__);
  21. $unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
  22. $allDirs = array(
  23. // absolute paths
  24. "$absSubDir\\",
  25. "$absSubDir\\..\\".$subDir,
  26. "$absSubDir\\\\..\\.\\".$subDir,
  27. "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
  28. "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
  29. "$absSubDir\\BADDIR",
  30. // relative paths
  31. $mainDir."\\".$subDir,
  32. $mainDir."\\\\".$subDir,
  33. $mainDir."\\\\\\".$subDir,
  34. ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
  35. "BADDIR",
  36. // unixifed path
  37. $unixifiedDir,
  38. );
  39. $filename = 'FileGetContentsVar7.tmp';
  40. $absFile = $absSubDir.'/'.$filename;
  41. $h = fopen($absFile,"w");
  42. fwrite($h, "contents read");
  43. fclose($h);
  44. for($i = 0; $i<count($allDirs); $i++) {
  45. $j = $i+1;
  46. $dir = $allDirs[$i];
  47. echo "\n-- Iteration $j --\n";
  48. var_dump(file($dir."\\".$filename));
  49. }
  50. unlink($absFile);
  51. chdir($old_dir_path);
  52. rmdir($absSubDir);
  53. rmdir($absMainDir);
  54. echo "\n*** Done ***\n";
  55. ?>
  56. --EXPECTF--
  57. *** Testing file() : variation ***
  58. -- Iteration 1 --
  59. array(1) {
  60. [0]=>
  61. string(13) "contents read"
  62. }
  63. -- Iteration 2 --
  64. array(1) {
  65. [0]=>
  66. string(13) "contents read"
  67. }
  68. -- Iteration 3 --
  69. array(1) {
  70. [0]=>
  71. string(13) "contents read"
  72. }
  73. -- Iteration 4 --
  74. array(1) {
  75. [0]=>
  76. string(13) "contents read"
  77. }
  78. -- Iteration 5 --
  79. Warning: file(%sfileVar8.dir\fileVar8Sub\..\\\fileVar8Sub\\..\\..\fileVar8Sub\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d
  80. bool(false)
  81. -- Iteration 6 --
  82. Warning: file(%sfileVar8.dir\fileVar8Sub\BADDIR\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d
  83. bool(false)
  84. -- Iteration 7 --
  85. array(1) {
  86. [0]=>
  87. string(13) "contents read"
  88. }
  89. -- Iteration 8 --
  90. array(1) {
  91. [0]=>
  92. string(13) "contents read"
  93. }
  94. -- Iteration 9 --
  95. array(1) {
  96. [0]=>
  97. string(13) "contents read"
  98. }
  99. -- Iteration 10 --
  100. array(1) {
  101. [0]=>
  102. string(13) "contents read"
  103. }
  104. -- Iteration 11 --
  105. Warning: file(BADDIR\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d
  106. bool(false)
  107. -- Iteration 12 --
  108. array(1) {
  109. [0]=>
  110. string(13) "contents read"
  111. }
  112. *** Done ***