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__;
58rmdir($file_path."/rename_variation_dir");
59?>
60--EXPECT--
61*** Testing rename() : renaming directory across directories ***
62-- Iteration 1 --
63bool(true)
64bool(false)
65bool(true)
66-- Iteration 2 --
67bool(true)
68bool(false)
69bool(true)
70-- Iteration 3 --
71bool(true)
72bool(false)
73bool(true)
74Done
75