1--TEST-- 2Test rename() function: usage variations 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die('skip.. only for Windows'); 7} 8?> 9--FILE-- 10<?php 11require __DIR__.'/file.inc'; 12 13/* creating directory */ 14$file_path = __DIR__; 15 16// rename dirs across directories 17echo "\n*** Testing rename() : renaming directory across directories ***\n"; 18$src_dirs = array ( 19 /* Testing simple directory tree */ 20 "$file_path/rename_variation/", 21 22 /* Testing a dir with trailing slash */ 23 "$file_path/rename_variation/", 24 25 /* Testing dir with double trailing slashes */ 26 "$file_path//rename_variation//", 27); 28 29$dest_dir = "$file_path/rename_variation_dir"; 30 31// create the $dest_dir 32mkdir($dest_dir); 33 34$counter = 1; 35 36/* loop through each $src_dirs and rename it to $dest_dir */ 37foreach($src_dirs as $src_dir) { 38 echo "-- Iteration $counter --\n"; 39 40 // create the src dir 41 mkdir("$file_path/rename_variation/"); 42 // rename the src dir to a new dir in dest dir 43 var_dump( rename($src_dir, $dest_dir."/new_dir") ); 44 // ensure that dir was renamed 45 var_dump( file_exists($src_dir) ); // expecting false 46 var_dump( file_exists($dest_dir."/new_dir") ); // expecting true 47 48 // remove the new dir 49 rmdir($dest_dir."/new_dir"); 50 $counter++; 51} 52 53echo "Done\n"; 54?> 55--CLEAN-- 56<?php 57$file_path = __DIR__; 58unlink($file_path."/rename_variation_link.tmp"); 59unlink($file_path."/rename_variation.tmp"); 60rmdir($file_path."/rename_variation_dir"); 61?> 62--EXPECT-- 63*** Testing rename() : renaming directory across directories *** 64-- Iteration 1 -- 65bool(true) 66bool(false) 67bool(true) 68-- Iteration 2 -- 69bool(true) 70bool(false) 71bool(true) 72-- Iteration 3 -- 73bool(true) 74bool(false) 75bool(true) 76Done 77