rename_variation8-win32.phpt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --TEST--
  2. Test rename() function: variation
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
  6. ?>
  7. --FILE--
  8. <?php
  9. echo "\n*** Testing rename() on non-existing file ***\n";
  10. $file_path = __DIR__;
  11. // try renaming a non existing file
  12. $src_name = $file_path."/non_existent_file.tmp";
  13. $dest_name = $file_path."/rename_variation8_new.tmp";
  14. var_dump( rename($src_name, $dest_name) );
  15. // ensure that $dest_name didn't get created
  16. var_dump( file_exists($src_name) ); // expecting false
  17. var_dump( file_exists($dest_name) ); // expecting false
  18. // rename a existing dir to new name
  19. echo "\n*** Testing rename() on existing directory ***\n";
  20. $dir_name = $file_path."/rename_basic_dir";
  21. mkdir($dir_name);
  22. $new_dir_name = $file_path."/rename_basic_dir1";
  23. var_dump( rename($dir_name, $new_dir_name) );
  24. //ensure that $new_dir_name got created
  25. var_dump( file_exists($dir_name) ); // expecting false
  26. var_dump( file_exists($new_dir_name) ); // expecting true
  27. // try to rename an non_existing dir
  28. echo "\n*** Testing rename() on non-existing directory ***\n";
  29. $non_existent_dir_name = $file_path."/non_existent_dir";
  30. $new_dir_name = "$file_path/rename_basic_dir2";
  31. var_dump( rename($non_existent_dir_name, $new_dir_name) );
  32. // ensure that $new_dir_name didn't get created
  33. var_dump( file_exists($non_existent_dir_name) ); // expecting flase
  34. var_dump( file_exists($new_dir_name) ); // expecting false
  35. echo "Done\n";
  36. ?>
  37. --CLEAN--
  38. <?php
  39. rmdir(__DIR__."/rename_basic_dir1");
  40. ?>
  41. --EXPECTF--
  42. *** Testing rename() on non-existing file ***
  43. Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): The system cannot find the file specified (code: 2) in %s on line %d
  44. bool(false)
  45. bool(false)
  46. bool(false)
  47. *** Testing rename() on existing directory ***
  48. bool(true)
  49. bool(false)
  50. bool(true)
  51. *** Testing rename() on non-existing directory ***
  52. Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): The system cannot find the file specified (code: 2) in %s on line %d
  53. bool(false)
  54. bool(false)
  55. bool(false)
  56. Done