Annotation of embedaddon/php/ext/standard/tests/file/rename_variation13.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. 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];
        !            44:   echo "-- testing '$name' --\n";  
        !            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' --
        !           101: bool(false)
        !           102: bool(false)
        !           103: -- testing 'Array' --
        !           104: 
        !           105: Warning: rename() expects parameter 2 to be string, array given in %s on line %d
        !           106: bool(false)
        !           107: 
        !           108: Warning: file_exists() expects parameter 1 to be string, array given in %s on line %d
        !           109: 
        !           110: Warning: rename() expects parameter 1 to be string, array given in %s on line %d
        !           111: bool(false)
        !           112: -- testing '/no/such/file/dir' --
        !           113: 
        !           114: Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
        !           115: bool(false)
        !           116: 
        !           117: Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
        !           118: bool(false)
        !           119: -- testing 'php/php' --
        !           120: 
        !           121: Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
        !           122: bool(false)
        !           123: 
        !           124: Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
        !           125: bool(false)
        !           126: 
        !           127: *** Done ***

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>