1--TEST--
2Test rename() function: basic functionality
3--FILE--
4<?php
5echo "*** Testing rename() on non-existing file ***\n";
6$file_path = __DIR__;
7require "$file_path/file.inc";
8
9$src_name = "$file_path/rename_basic.tmp";
10$dest_name = "$file_path/rename_basic_new.tmp";
11
12// create the file
13$fp = fopen($src_name, "w");
14$old_stat = stat($src_name);
15fclose($fp);
16
17var_dump( rename($src_name, $dest_name) ); // expecting true
18var_dump( file_exists($src_name) ); // expecting false
19var_dump( file_exists($dest_name) ); // expecting true
20
21$new_stat = stat("$file_path/rename_basic_new.tmp");
22
23// checking statistics of old and renamed file - both should be same except ctime
24$keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12,
25                       "dev", "ino", "mode", "nlink", "uid", "gid",
26                       "rdev", "size", "atime", "mtime", "blksize", "blocks");
27var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) );
28
29?>
30--CLEAN--
31<?php
32unlink(__DIR__."/rename_basic_new.tmp");
33?>
34--EXPECT--
35*** Testing rename() on non-existing file ***
36bool(true)
37bool(false)
38bool(true)
39bool(true)
40