summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file/rename_variation13.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/file/rename_variation13.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/file/rename_variation13.phpt')
-rw-r--r--ext/standard/tests/file/rename_variation13.phpt133
1 files changed, 133 insertions, 0 deletions
diff --git a/ext/standard/tests/file/rename_variation13.phpt b/ext/standard/tests/file/rename_variation13.phpt
new file mode 100644
index 0000000..ec1ee7c
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation13.phpt
@@ -0,0 +1,133 @@
+--TEST--
+Test rename() function : variation - various invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip. Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rename() with obscure files ***\n";
+$file_path = dirname(__FILE__)."/renameVar13";
+$aFile = $file_path.'/afile.tmp';
+
+mkdir($file_path);
+
+/* An array of files */
+$names_arr = array(
+ /* Invalid args */
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ array(),
+
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir",
+ "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+ $name = $names_arr[$i];
+ echo @"-- testing '$name' --\n";
+ touch($aFile);
+ var_dump(rename($aFile, $name));
+ if (file_exists($name)) {
+ unlink($name);
+ }
+ if (file_exists($aFile)) {
+ unlink($aFile);
+ }
+ var_dump(rename($name, $aFile));
+ if (file_exists($aFile)) {
+ unlink($aFile);
+ }
+}
+
+rmdir($file_path);
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with obscure files ***
+-- testing '-1' --
+bool(true)
+
+Warning: rename(-1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '1' --
+bool(true)
+
+Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
+bool(false)
+-- testing ' ' --
+bool(true)
+
+Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '%s' --
+
+Warning: rename() %s in %s on line %d
+bool(false)
+
+Warning: file_exists() expects parameter 1 to be a valid path, string given in %s on line %d
+
+Warning: rename() expects parameter 1 to be a valid path, string given in %s on line %d
+bool(false)
+-- testing 'Array' --
+
+Warning: rename() expects parameter 2 to be a valid path, array given in %s on line %d
+bool(false)
+
+Warning: file_exists() expects parameter 1 to be a valid path, array given in %s on line %d
+
+Warning: rename() expects parameter 1 to be a valid path, array given in %s on line %d
+bool(false)
+-- testing '/no/such/file/dir' --
+
+Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
+bool(false)
+
+Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing 'php/php' --
+
+Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
+bool(false)
+
+Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
+bool(false)
+
+*** Done ***