realpath_variation-win32-mb.phpt 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --TEST--
  2. Test realpath() function: usage variation
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die('skip only on Windows');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. require __DIR__.'/file.inc';
  12. echo "*** Testing realpath(): usage variations ***\n";
  13. $name_prefix = __DIR__;
  14. $filename = "$name_prefix/realpath_variation_私はガラスを食べられます/home/tests/realpath_variation_私はガラスを食べられます.tmp";
  15. mkdir("$name_prefix/realpath_variation_私はガラスを食べられます/home/tests/", 0777, true);
  16. echo "\n*** Testing realpath() with filename stored inside a object ***\n";
  17. // create a temp file
  18. $file_handle = fopen($filename, "w");
  19. fclose($file_handle);
  20. // creating object with members as filename
  21. class object_temp {
  22. public $filename;
  23. function __construct($file) {
  24. $this->filename = $file;
  25. }
  26. }
  27. $obj1 = new object_temp("$name_prefix/realpath_variation_私はガラスを食べられます/../././realpath_variation_私はガラスを食べられます/home/tests/realpath_variation_私はガラスを食べられます.tmp");
  28. $obj2 = new object_temp("$name_prefix/realpath_variation_私はガラスを食べられます/home/..///realpath_variation_私はガラスを食べられます.tmp");
  29. var_dump( realpath($obj1->filename) );
  30. var_dump( realpath($obj2->filename) );
  31. echo "\n*** Testing realpath() with filename stored in an array ***\n";
  32. $file_arr = array (
  33. "$name_prefix////realpath_variation_私はガラスを食べられます/home/tests/realpath_variation_私はガラスを食べられます.tmp",
  34. "$name_prefix/./realpath_variation_私はガラスを食べられます/home/../home//tests//..//..//..//home//realpath_variation_私はガラスを食べられます.tmp/"
  35. );
  36. var_dump( realpath($file_arr[0]) );
  37. var_dump( realpath($file_arr[1]) );
  38. echo "\n*** Testing realpath() with filename as empty string, NULL and single space ***\n";
  39. $file_string = array (
  40. /* filename as spaces */
  41. " ",
  42. ' ',
  43. /* empty filename */
  44. "",
  45. '',
  46. );
  47. for($loop_counter = 0; $loop_counter < count($file_string); $loop_counter++) {
  48. echo "-- Iteration";
  49. echo $loop_counter + 1;
  50. echo " --\n";
  51. var_dump( realpath($file_string[$loop_counter]) );
  52. }
  53. echo "Done\n";
  54. ?>
  55. --CLEAN--
  56. <?php
  57. $name_prefix = __DIR__."/realpath_variation_私はガラスを食べられます";
  58. unlink("$name_prefix/home/tests/realpath_variation_私はガラスを食べられます.tmp");
  59. rmdir("$name_prefix/home/tests/");
  60. rmdir("$name_prefix/home/");
  61. rmdir("$name_prefix/");
  62. ?>
  63. --EXPECTF--
  64. *** Testing realpath(): usage variations ***
  65. *** Testing realpath() with filename stored inside a object ***
  66. string(%d) "%s\realpath_variation_私はガラスを食べられます\home\tests\realpath_variation_私はガラスを食べられます.tmp"
  67. bool(false)
  68. *** Testing realpath() with filename stored in an array ***
  69. string(%d) "%s\realpath_variation_私はガラスを食べられます\home\tests\realpath_variation_私はガラスを食べられます.tmp"
  70. bool(false)
  71. *** Testing realpath() with filename as empty string, NULL and single space ***
  72. -- Iteration1 --
  73. bool(false)
  74. -- Iteration2 --
  75. bool(false)
  76. -- Iteration3 --
  77. string(%d) "%s"
  78. -- Iteration4 --
  79. string(%d) "%s"
  80. Done