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