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
11/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
12   Description: Renames a file or directory
13*/
14
15require __DIR__.'/file.inc';
16
17$file_path = __DIR__;
18mkdir("$file_path/rename_variation2_dir");
19
20/* Renaming a file and directory to numeric name */
21echo "\n*** Testing rename() by renaming a file and directory to numeric name ***\n";
22$fp = fopen($file_path."/rename_variation2.tmp", "w");
23fclose($fp);
24
25// renaming existing file to numeric name
26var_dump( rename($file_path."/rename_variation2.tmp", $file_path."/12345") );
27
28// ensure that rename worked fine
29var_dump( file_exists($file_path."/rename_variation2.tmp" ) );  // expecting false
30var_dump( file_exists($file_path."/12345" ) );  // expecting true
31
32unlink($file_path."/12345");
33
34// renaming a directory to numeric name
35var_dump( rename($file_path."/rename_variation2_dir/", $file_path."/12345") );
36
37// ensure that rename worked fine
38var_dump( file_exists($file_path."/rename_variation2_dir" ) );  // expecting false
39var_dump( file_exists($file_path."/12345" ) );  // expecting true
40
41rmdir($file_path."/12345");
42
43echo "Done\n";
44?>
45--CLEAN--
46<?php
47$file_path = __DIR__;
48unlink($file_path."/rename_variation2_link.tmp");
49unlink($file_path."/rename_variation2.tmp");
50rmdir($file_path."/rename_variation2_dir");
51?>
52--EXPECT--
53*** Testing rename() by renaming a file and directory to numeric name ***
54bool(true)
55bool(false)
56bool(true)
57bool(true)
58bool(false)
59bool(true)
60Done
61