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