Annotation of embedaddon/php/ext/standard/tests/file/rename_variation13-win32.phpt, revision 1.1
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 run only on 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: /* An array of files */
! 18: $names_arr = array(
! 19: /* Invalid args */
! 20: -1, /* -1 is just a valid filename on windows */
! 21: TRUE, /* 1 as well, (string)TRUE > "1" */
! 22: FALSE,
! 23: NULL,
! 24: "", // I think both p8 and php are wrong on the messages here
! 25: //p8 generates different messages to php, php is probably wrong
! 26: //php has either "File Exists" or "Permission Denied".
! 27: " ",
! 28: "\0",
! 29:
! 30: // as before
! 31: array(),
! 32:
! 33: /* prefix with path separator of a non existing directory*/
! 34: "/no/such/file/dir",
! 35: "php/php"
! 36:
! 37: );
! 38:
! 39: /* disable notice so we don't get the array to string conversion notice for "$name" where $name = array() */
! 40: error_reporting(E_ALL ^ E_NOTICE);
! 41:
! 42: echo "*** Testing rename() with obscure files ***\n";
! 43: $file_path = dirname(__FILE__)."/renameVar13";
! 44: $aFile = $file_path.'/afile.tmp';
! 45:
! 46: if (!mkdir($file_path)) {
! 47: die("fail to create $file_path tmp dir");
! 48: }
! 49:
! 50: for( $i=0; $i < count($names_arr); $i++ ) {
! 51: $name = $names_arr[$i];
! 52: echo "-- $i testing '$name' " . gettype($name) . " --\n";
! 53:
! 54: touch($aFile);
! 55: var_dump(rename($aFile, $name));
! 56: if (file_exists($name)) {
! 57: @unlink($name);
! 58: }
! 59:
! 60: if (file_exists($aFile)) {
! 61: @unlink($aFile);
! 62: }
! 63: var_dump(rename($name, $aFile));
! 64: if (file_exists($aFile)) {
! 65: @unlink($aFile);
! 66: }
! 67: }
! 68:
! 69: rmdir($file_path);
! 70: echo "\n*** Done ***\n";
! 71: ?>
! 72: --EXPECTF--
! 73: *** Testing rename() with obscure files ***
! 74: -- 0 testing '-1' integer --
! 75: bool(true)
! 76:
! 77: Warning: rename(-1,%s/renameVar13/afile.tmp): The system cannot find the file specified. (code: 2) in %s on line %d
! 78: bool(false)
! 79: -- 1 testing '1' boolean --
! 80: bool(true)
! 81:
! 82: Warning: rename(1,%s/renameVar13/afile.tmp): The system cannot find the file specified. (code: 2) in %s on line %d
! 83: bool(false)
! 84: -- 2 testing '' boolean --
! 85:
! 86: Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
! 87: bool(false)
! 88:
! 89: Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
! 90: bool(false)
! 91: -- 3 testing '' NULL --
! 92:
! 93: Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
! 94: bool(false)
! 95:
! 96: Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
! 97: bool(false)
! 98: -- 4 testing '' string --
! 99:
! 100: Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
! 101: bool(false)
! 102:
! 103: Warning: rename(,%s/renameVar13/afile.tmp):%s in %s on line %d
! 104: bool(false)
! 105: -- 5 testing ' ' string --
! 106:
! 107: Warning: rename(%s/renameVar13/afile.tmp, ): The filename, directory name, or volume label syntax is incorrect. (code: 123) in %s on line %d
! 108: bool(false)
! 109:
! 110: Warning: rename( ,%s/renameVar13/afile.tmp): The filename, directory name, or volume label syntax is incorrect. (code: 123) in %s on line %d
! 111: bool(false)
! 112: -- 6 testing '
! 113: bool(false)
! 114: bool(false)
! 115: -- 7 testing 'Array' array --
! 116:
! 117: Warning: rename() expects parameter 2 to be string, array given in %s on line %d
! 118: bool(false)
! 119:
! 120: Warning: file_exists() expects parameter 1 to be string, array given in %s on line %d
! 121:
! 122: Warning: rename() expects parameter 1 to be string, array given in %s on line %d
! 123: bool(false)
! 124: -- 8 testing '/no/such/file/dir' string --
! 125:
! 126: Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): The system cannot find the path specified. (code: 3) in %s on line %d
! 127: bool(false)
! 128:
! 129: Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
! 130: bool(false)
! 131: -- 9 testing 'php/php' string --
! 132:
! 133: Warning: rename(%s/renameVar13/afile.tmp,php/php): The system cannot find the path specified. (code: 3) in %s on line %d
! 134: bool(false)
! 135:
! 136: Warning: rename(php/php,%s/renameVar13/afile.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
! 137: bool(false)
! 138:
! 139: *** Done ***
! 140:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>