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  NULL,
27  "",
28  " ",
29
30  /* prefix with path separator of a non existing directory*/
31  "/no/such/file/dir",
32  "php/php"
33
34);
35
36for( $i=0; $i<count($names_arr); $i++ ) {
37  $name = $names_arr[$i];
38  echo @"-- testing '$name' --\n";
39  touch($aFile);
40  var_dump(rename($aFile, $name));
41  if (file_exists($name)) {
42     unlink($name);
43  }
44  if (file_exists($aFile)) {
45     unlink($aFile);
46  }
47  var_dump(rename($name, $aFile));
48  if (file_exists($aFile)) {
49     unlink($aFile);
50  }
51}
52
53rmdir($file_path);
54?>
55--EXPECTF--
56*** Testing rename() with obscure files ***
57-- testing '-1' --
58bool(true)
59
60Warning: rename(-1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
61bool(false)
62-- testing '1' --
63bool(true)
64
65Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
66bool(false)
67-- testing '' --
68
69Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
70bool(false)
71
72Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
73bool(false)
74-- testing '' --
75
76Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
77bool(false)
78
79Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
80bool(false)
81-- testing '' --
82
83Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
84bool(false)
85
86Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
87bool(false)
88-- testing ' ' --
89bool(true)
90
91Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
92bool(false)
93-- testing '/no/such/file/dir' --
94
95Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
96bool(false)
97
98Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
99bool(false)
100-- testing 'php/php' --
101
102Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
103bool(false)
104
105Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
106bool(false)
107