Annotation of embedaddon/php/ext/standard/tests/file/rename_variation13.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test rename() function : variation - various invalid paths
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --SKIPIF--
6: <?php
7: if(substr(PHP_OS, 0, 3) == "WIN")
8: die("skip. Not for Windows");
9: ?>
10: --FILE--
11: <?php
12: /* Prototype : bool rename(string old_name, string new_name[, resource context])
13: * Description: Rename a file
14: * Source code: ext/standard/file.c
15: * Alias to functions:
16: */
17:
18: echo "*** Testing rename() with obscure files ***\n";
19: $file_path = dirname(__FILE__)."/renameVar13";
20: $aFile = $file_path.'/afile.tmp';
21:
22: mkdir($file_path);
23:
24: /* An array of files */
25: $names_arr = array(
26: /* Invalid args */
27: -1,
28: TRUE,
29: FALSE,
30: NULL,
31: "",
32: " ",
33: "\0",
34: array(),
35:
36: /* prefix with path separator of a non existing directory*/
37: "/no/such/file/dir",
38: "php/php"
39:
40: );
41:
42: for( $i=0; $i<count($names_arr); $i++ ) {
43: $name = $names_arr[$i];
1.1.1.2 ! misho 44: echo @"-- testing '$name' --\n";
1.1 misho 45: touch($aFile);
46: var_dump(rename($aFile, $name));
47: if (file_exists($name)) {
48: unlink($name);
49: }
50: if (file_exists($aFile)) {
51: unlink($aFile);
52: }
53: var_dump(rename($name, $aFile));
54: if (file_exists($aFile)) {
55: unlink($aFile);
56: }
57: }
58:
59: rmdir($file_path);
60: echo "\n*** Done ***\n";
61: ?>
62: --EXPECTF--
63: *** Testing rename() with obscure files ***
64: -- testing '-1' --
65: bool(true)
66:
67: Warning: rename(-1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
68: bool(false)
69: -- testing '1' --
70: bool(true)
71:
72: Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
73: bool(false)
74: -- testing '' --
75:
76: Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
77: bool(false)
78:
79: Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
80: bool(false)
81: -- testing '' --
82:
83: Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
84: bool(false)
85:
86: Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
87: bool(false)
88: -- testing '' --
89:
90: Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
91: bool(false)
92:
93: Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
94: bool(false)
95: -- testing ' ' --
96: bool(true)
97:
98: Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
99: bool(false)
100: -- testing '%s' --
1.1.1.2 ! misho 101:
! 102: Warning: rename() %s in %s on line %d
1.1 misho 103: bool(false)
1.1.1.2 ! misho 104:
! 105: Warning: file_exists() expects parameter 1 to be a valid path, string given in %s on line %d
! 106:
! 107: Warning: rename() expects parameter 1 to be a valid path, string given in %s on line %d
1.1 misho 108: bool(false)
109: -- testing 'Array' --
110:
1.1.1.2 ! misho 111: Warning: rename() expects parameter 2 to be a valid path, array given in %s on line %d
1.1 misho 112: bool(false)
113:
1.1.1.2 ! misho 114: Warning: file_exists() expects parameter 1 to be a valid path, array given in %s on line %d
1.1 misho 115:
1.1.1.2 ! misho 116: Warning: rename() expects parameter 1 to be a valid path, array given in %s on line %d
1.1 misho 117: bool(false)
118: -- testing '/no/such/file/dir' --
119:
120: Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
121: bool(false)
122:
123: Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
124: bool(false)
125: -- testing 'php/php' --
126:
127: Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
128: bool(false)
129:
130: Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
131: bool(false)
132:
133: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>