rename_variation3-win32.phpt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. Test rename() function: usage variations
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die('skip.. only for Windows');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. require __DIR__.'/file.inc';
  12. /* creating directory */
  13. $file_path = __DIR__;
  14. $dirname = "$file_path/rename_variation3_dir";
  15. mkdir($dirname);
  16. /* test rename() by trying to rename an existing file/dir to the same name
  17. and one another */
  18. $filename = "$file_path/rename_variation3.tmp";
  19. $fp = fopen($filename, "w");
  20. if (!$fp) {
  21. die("Cannot create $filename\n");
  22. }
  23. fclose($fp);
  24. echo "\n-- Renaming file to same file name --\n";
  25. var_dump( rename($filename, $filename) );
  26. var_dump( file_exists($filename) );
  27. echo "\n-- Renaming directory to same directory name --\n";
  28. var_dump( rename($dirname, $dirname) );
  29. var_dump( file_exists($dirname) );
  30. echo "\n-- Renaming existing file to existing directory name --\n";
  31. var_dump( rename($filename, $dirname) );
  32. var_dump( file_exists($filename) );
  33. var_dump( file_exists($dirname) );
  34. echo "\n-- Renaming existing directory to existing file name --\n";
  35. $fp = fopen($filename, "w");
  36. fclose($fp);
  37. var_dump( rename($dirname, $filename) );
  38. var_dump( file_exists($filename) );
  39. var_dump( file_exists($dirname) );
  40. echo "Done\n";
  41. ?>
  42. --CLEAN--
  43. <?php
  44. $file_path = __DIR__;
  45. unlink($file_path."/rename_variation3_link.tmp");
  46. unlink($file_path."/rename_variation3.tmp");
  47. rmdir($file_path."/rename_variation3_dir");
  48. rmdir($file_path."/rename_variation3.tmp");
  49. ?>
  50. --EXPECTF--
  51. -- Renaming file to same file name --
  52. bool(true)
  53. bool(true)
  54. -- Renaming directory to same directory name --
  55. bool(true)
  56. bool(true)
  57. -- Renaming existing file to existing directory name --
  58. Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): Access is denied (code: 5) in %s on line %d
  59. bool(false)
  60. bool(true)
  61. bool(true)
  62. -- Renaming existing directory to existing file name --
  63. bool(true)
  64. bool(true)
  65. bool(false)
  66. Done