rename_variation2-win32.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
  12. Description: Renames a file or directory
  13. */
  14. require dirname(__FILE__).'/file.inc';
  15. $file_path = dirname(__FILE__);
  16. mkdir("$file_path/rename_variation2_dir");
  17. /* Renaming a file and directory to numeric name */
  18. echo "\n*** Testing rename() by renaming a file and directory to numeric name ***\n";
  19. $fp = fopen($file_path."/rename_variation2.tmp", "w");
  20. fclose($fp);
  21. // renaming existing file to numeric name
  22. var_dump( rename($file_path."/rename_variation2.tmp", $file_path."/12345") );
  23. // ensure that rename worked fine
  24. var_dump( file_exists($file_path."/rename_variation2.tmp" ) ); // expecting false
  25. var_dump( file_exists($file_path."/12345" ) ); // expecting true
  26. unlink($file_path."/12345");
  27. // renaming a directory to numeric name
  28. var_dump( rename($file_path."/rename_variation2_dir/", $file_path."/12345") );
  29. // ensure that rename worked fine
  30. var_dump( file_exists($file_path."/rename_variation2_dir" ) ); // expecting false
  31. var_dump( file_exists($file_path."/12345" ) ); // expecting true
  32. rmdir($file_path."/12345");
  33. echo "Done\n";
  34. ?>
  35. --CLEAN--
  36. <?php
  37. $file_path = dirname(__FILE__);
  38. unlink($file_path."/rename_variation2_link.tmp");
  39. unlink($file_path."/rename_variation2.tmp");
  40. rmdir($file_path."/rename_variation2_dir");
  41. ?>
  42. --EXPECTF--
  43. *** Testing rename() by renaming a file and directory to numeric name ***
  44. bool(true)
  45. bool(false)
  46. bool(true)
  47. bool(true)
  48. bool(false)
  49. bool(true)
  50. Done