rename_variation9.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Test rename() function: basic functionality
  3. --FILE--
  4. <?php
  5. echo "\n*** Testing rename() by giving stream context as third argument ***\n";
  6. $file_path = __DIR__;
  7. $context = stream_context_create();
  8. // on directory
  9. $dir_name = "$file_path/rename_variation_dir9";
  10. $new_dir_name = "$file_path/rename_variation_dir9_new";
  11. mkdir($dir_name);
  12. var_dump( rename($dir_name, $new_dir_name, $context) );
  13. var_dump( file_exists($dir_name) ); // expecting flase
  14. var_dump( file_exists($new_dir_name) ); // expecting true
  15. //on file
  16. $src_name = "$file_path/rename_variation9.tmp";
  17. $dest_name = "$file_path/rename_variation9_new.tmp";
  18. // create the file
  19. $fp = fopen($src_name, "w");
  20. $s1 = stat($src_name);
  21. fclose($fp);
  22. var_dump( rename($src_name, $dest_name, $context) );
  23. var_dump( file_exists($src_name) ); // expecting false
  24. var_dump( file_exists($dest_name) ); // expecting true
  25. echo "Done\n";
  26. ?>
  27. --CLEAN--
  28. <?php
  29. unlink(__DIR__."/rename_variation9_new.tmp");
  30. rmdir(__DIR__."/rename_variation_dir9_new");
  31. ?>
  32. --EXPECT--
  33. *** Testing rename() by giving stream context as third argument ***
  34. bool(true)
  35. bool(false)
  36. bool(true)
  37. bool(true)
  38. bool(false)
  39. bool(true)
  40. Done