1--TEST--
2Test rename() function: variation
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') die('skip..  not for Windows');
6?>
7--FILE--
8<?php
9echo "\n*** Testing rename() on non-existing file ***\n";
10$file_path = __DIR__;
11
12// try renaming a non existing file
13$src_name = $file_path."/non_existent_file.tmp";
14$dest_name = $file_path."/rename_variation8_new.tmp";
15var_dump( rename($src_name, $dest_name) );
16
17// ensure that $dest_name didn't get created
18var_dump( file_exists($src_name) );  // expecting false
19var_dump( file_exists($dest_name) ); // expecting false
20
21// rename a existing dir to new name
22echo "\n*** Testing rename() on existing directory ***\n";
23$dir_name = $file_path."/rename_basic_dir";
24mkdir($dir_name);
25$new_dir_name = $file_path."/rename_basic_dir1";
26var_dump( rename($dir_name, $new_dir_name) );
27//ensure that $new_dir_name got created
28var_dump( file_exists($dir_name) );  // expecting false
29var_dump( file_exists($new_dir_name) );  // expecting true
30
31// try to rename an non_existing dir
32echo "\n*** Testing rename() on non-existing directory ***\n";
33$non_existent_dir_name = $file_path."/non_existent_dir";
34$new_dir_name = "$file_path/rename_basic_dir2";
35var_dump( rename($non_existent_dir_name, $new_dir_name) );
36// ensure that $new_dir_name didn't get created
37var_dump( file_exists($non_existent_dir_name) );  // expecting flase
38var_dump( file_exists($new_dir_name) );  // expecting false
39
40echo "Done\n";
41?>
42--CLEAN--
43<?php
44rmdir(__DIR__."/rename_basic_dir1");
45?>
46--EXPECTF--
47*** Testing rename() on non-existing file ***
48
49Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): No such file or directory in %s on line %d
50bool(false)
51bool(false)
52bool(false)
53
54*** Testing rename() on existing directory ***
55bool(true)
56bool(false)
57bool(true)
58
59*** Testing rename() on non-existing directory ***
60
61Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): No such file or directory in %s on line %d
62bool(false)
63bool(false)
64bool(false)
65Done
66