Annotation of embedaddon/php/ext/standard/tests/file/rename_variation12-win32.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test rename() function : variation - various relative, absolute paths
                      3: --CREDITS--
                      4: Dave Kelsey <d_kelsey@uk.ibm.com>
                      5: --SKIPIF--
                      6: <?php
                      7: if (substr(PHP_OS, 0, 3) != 'WIN') die('skip..  for Windows');
                      8: ?>
                      9: --FILE--
                     10: <?php
                     11: /* Prototype  : bool rename(string old_name, string new_name[, resource context])
                     12:  * Description: Rename a file 
                     13:  * Source code: ext/standard/file.c
                     14:  * Alias to functions: 
                     15:  */
                     16: 
                     17: /* Creating unique files in various dirs by passing relative paths to $dir arg */
                     18: 
                     19: echo "*** Testing rename() with absolute and relative paths ***\n";
                     20: $mainDir = "renameVar11";
                     21: $subDir = "renameVar11Sub";
                     22: $absMainDir = dirname(__FILE__)."/".$mainDir;
                     23: mkdir($absMainDir);
                     24: $absSubDir = $absMainDir."/".$subDir;
                     25: mkdir($absSubDir);
                     26: 
                     27: $fromFile = "renameMe.tmp";
                     28: $toFile = "IwasRenamed.tmp";
                     29: 
                     30: $old_dir_path = getcwd();
                     31: chdir(dirname(__FILE__));
                     32: 
                     33: $allDirs = array(
                     34:   // absolute paths
                     35:   "$absSubDir/",
                     36:   "$absSubDir/../".$subDir,
                     37:   "$absSubDir//.././".$subDir,
                     38:   "$absSubDir/../../".$mainDir."/./".$subDir,
                     39:   "$absSubDir/..///".$subDir."//..//../".$subDir,
                     40:   "$absSubDir/BADDIR",
                     41:   
                     42:   
                     43:   // relative paths
                     44:   $mainDir."/".$subDir,
                     45:   $mainDir."//".$subDir, 
                     46:    $mainDir."///".$subDir, 
                     47:   "./".$mainDir."/../".$mainDir."/".$subDir,
                     48:   "BADDIR",  
                     49: );
                     50: 
                     51: for($i = 0; $i<count($allDirs); $i++) {
                     52:   $j = $i+1;
                     53:   $dir = $allDirs[$i];
                     54:   echo "\n-- Iteration $j --\n";
                     55:   touch($absSubDir."/".$fromFile);
                     56:   $res = rename($dir."/".$fromFile, $dir."/".$toFile);
                     57:   var_dump($res);
                     58:   if ($res == true) {
                     59:      $res = rename($dir."/".$toFile, $dir."/".$fromFile);
                     60:      var_dump($res);
                     61:   }
                     62:   unlink($absSubDir."/".$fromFile);
                     63: }
                     64: 
                     65: chdir($old_dir_path);
                     66: rmdir($absSubDir);
                     67: rmdir($absMainDir);
                     68: 
                     69: echo "\n*** Done ***\n";
                     70: ?>
                     71: --EXPECTF--
                     72: *** Testing rename() with absolute and relative paths ***
                     73: 
                     74: -- Iteration 1 --
                     75: bool(true)
                     76: bool(true)
                     77: 
                     78: -- Iteration 2 --
                     79: bool(true)
                     80: bool(true)
                     81: 
                     82: -- Iteration 3 --
                     83: bool(true)
                     84: bool(true)
                     85: 
                     86: -- Iteration 4 --
                     87: bool(true)
                     88: bool(true)
                     89: 
                     90: -- Iteration 5 --
                     91: 
                     92: Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
                     93: bool(false)
                     94: 
                     95: -- Iteration 6 --
                     96: 
                     97: Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
                     98: bool(false)
                     99: 
                    100: -- Iteration 7 --
                    101: bool(true)
                    102: bool(true)
                    103: 
                    104: -- Iteration 8 --
                    105: bool(true)
                    106: bool(true)
                    107: 
                    108: -- Iteration 9 --
                    109: bool(true)
                    110: bool(true)
                    111: 
                    112: -- Iteration 10 --
                    113: bool(true)
                    114: bool(true)
                    115: 
                    116: -- Iteration 11 --
                    117: 
                    118: Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
                    119: bool(false)
                    120: 
                    121: *** Done ***

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