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