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