rename_variation4.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Test rename() function: usage variations-5
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) == 'WIN') {
  6. die('skip.. only for Linux');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. $file_path = __DIR__;
  12. require __DIR__.'/file.inc';
  13. /* Renaming a file, link and directory to numeric name */
  14. echo "\n*** Testing rename() by renaming a file, link and directory to numeric name ***\n";
  15. $fp = fopen($file_path."/rename_variation4.tmp", "w");
  16. fclose($fp);
  17. // renaming existing file to numeric name
  18. var_dump( rename($file_path."/rename_variation4.tmp", $file_path."/12345") );
  19. // ensure that rename worked fine
  20. var_dump( file_exists($file_path."/rename_variation4.tmp" ) ); // expecting false
  21. var_dump( file_exists($file_path."/12345" ) ); // expecting true
  22. // remove the file
  23. unlink($file_path."/12345");
  24. mkdir($file_path."/rename_variation4_dir");
  25. // renaming a directory to numeric name
  26. var_dump( rename($file_path."/rename_variation4_dir/", $file_path."/12345") );
  27. // ensure that rename worked fine
  28. var_dump( file_exists($file_path."/rename_variation4_dir" ) ); // expecting false
  29. var_dump( file_exists($file_path."/12345" ) ); // expecting true
  30. echo "Done\n";
  31. ?>
  32. --CLEAN--
  33. <?php
  34. $file_path = __DIR__;
  35. rmdir($file_path."/12345");
  36. ?>
  37. --EXPECT--
  38. *** Testing rename() by renaming a file, link and directory to numeric name ***
  39. bool(true)
  40. bool(false)
  41. bool(true)
  42. bool(true)
  43. bool(false)
  44. bool(true)
  45. Done