File: rename_variation3-win32.phpt

package info (click to toggle)
php5 5.2.6.dfsg.1-1%2Blenny16
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 81,956 kB
  • ctags: 45,717
  • sloc: ansic: 545,818; sh: 18,463; php: 12,555; xml: 4,362; yacc: 2,430; lex: 2,294; makefile: 1,193; tcl: 1,128; awk: 693; cpp: 682; perl: 71; pascal: 24; sql: 22
file content (69 lines) | stat: -rw-r--r-- 1,762 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--TEST--
Test rename() function: usage variations
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') {
    die('skip.. only for Windows');
}
?>
--FILE--
<?php
/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
   Description: Renames a file or directory
*/

require dirname(__FILE__).'/file.inc';

/* creating directory */
$file_path = dirname(__FILE__);
$dirname = "$file_path/rename_variation_dir"; 
mkdir($dirname);

/* test rename() by trying to rename an existing file/dir to the same name
  and one another */

$filename = "$file_path/rename_variation.tmp"; 
$fp = fopen($filename, "w");
fclose($fp);

echo "\n-- Renaming file to same file name --\n";
var_dump( rename($filename, $filename) );

echo "\n-- Renaming directory to same directory name --\n";
var_dump( rename($dirname, $dirname) );

echo "\n-- Renaming existing file to existing directory name --\n";
var_dump( rename($filename, $dirname) );

echo "\n-- Renaming existing directory to existing file name --\n";
$fp = fopen($filename, "w");
fclose($fp);
var_dump( rename($dirname, $filename) );

echo "Done\n";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."/rename_variation_link.tmp");
unlink($file_path."/rename_variation.tmp");
rmdir($file_path."/rename_variation_dir");
?>
--EXPECTF--
-- Renaming file to same file name --
bool(true)

-- Renaming directory to same directory name --
bool(true)

-- Renaming existing file to existing directory name --

Warning: rename(%s/rename_variation.tmp,%s/rename_variation_dir): File exists in %s on line %d
bool(false)

-- Renaming existing directory to existing file name --

Warning: rename(%s/rename_variation_dir,%s/rename_variation.tmp): File exists in %s on line %d
bool(false)
Done