1--TEST--
2Test rename() function : variation - various invalid paths
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) == "WIN")
8  die("skip. Not for Windows");
9?>
10--CONFLICTS--
11obscure_filename
12--FILE--
13<?php
14echo "*** Testing rename() with obscure files ***\n";
15$file_path = __DIR__."/renameVar13";
16$aFile = $file_path.'/afile.tmp';
17
18mkdir($file_path);
19
20/* An array of files */
21$names_arr = array(
22  /* Invalid args */
23  -1,
24  TRUE,
25  FALSE,
26  "",
27  " ",
28
29  /* prefix with path separator of a non existing directory*/
30  "/no/such/file/dir",
31  "php/php"
32
33);
34
35for( $i=0; $i<count($names_arr); $i++ ) {
36  $name = $names_arr[$i];
37  echo @"-- testing '$name' --\n";
38  touch($aFile);
39  var_dump(rename($aFile, $name));
40  if (file_exists($name)) {
41     unlink($name);
42  }
43  if (file_exists($aFile)) {
44     unlink($aFile);
45  }
46  var_dump(rename($name, $aFile));
47  if (file_exists($aFile)) {
48     unlink($aFile);
49  }
50}
51
52rmdir($file_path);
53?>
54--EXPECTF--
55*** Testing rename() with obscure files ***
56-- testing '-1' --
57bool(true)
58
59Warning: rename(-1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
60bool(false)
61-- testing '1' --
62bool(true)
63
64Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
65bool(false)
66-- testing '' --
67
68Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
69bool(false)
70
71Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
72bool(false)
73-- testing '' --
74
75Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
76bool(false)
77
78Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
79bool(false)
80-- testing ' ' --
81bool(true)
82
83Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
84bool(false)
85-- testing '/no/such/file/dir' --
86
87Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
88bool(false)
89
90Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
91bool(false)
92-- testing 'php/php' --
93
94Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
95bool(false)
96
97Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
98bool(false)
99