Annotation of embedaddon/php/ext/standard/tests/file/rename_variation.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test rename() function: usage variations-1 (Bug#42638)
        !             3: --SKIPIF--
        !             4: <?php
        !             5: if (substr(PHP_OS, 0, 3) == 'WIN') {
        !             6:     die('skip.. only for Linux');
        !             7: }
        !             8: ?>
        !             9: --FILE--
        !            10: <?php
        !            11: 
        !            12: /* creating directory */
        !            13: $file_path = dirname(__FILE__);
        !            14: mkdir("$file_path/rename_variation");
        !            15: 
        !            16: /* rename files across directories */
        !            17: echo "*** Testing rename() : rename files across directories ***\n";
        !            18: $src_filenames = array(
        !            19:   "$file_path/rename_variation/rename_variation.tmp",
        !            20: 
        !            21:   /* Testing a file trailing slash */
        !            22:   "$file_path/rename_variation/rename_variation.tmp/",
        !            23: 
        !            24:   /* Testing file with double slashes */
        !            25:   "$file_path/rename_variation//rename_variation.tmp",
        !            26:   "$file_path//rename_variation//rename_variation.tmp",
        !            27: );
        !            28: $counter = 1;
        !            29: /* loop through each $file and rename it to rename_variation2.tmp */
        !            30: foreach($src_filenames as $src_filename) {
        !            31:   echo "-- Iteration $counter --\n";
        !            32:   $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w");
        !            33:   fclose($fp);
        !            34:   $dest_filename = "$file_path/rename_variation2.tmp";
        !            35:   var_dump( rename($src_filename, $dest_filename) );
        !            36:   // ensure that file got renamed to new name 
        !            37:   var_dump( file_exists($src_filename) );  // expecting false
        !            38:   var_dump( file_exists($dest_filename) );  // expecting true
        !            39:   $counter++;
        !            40:  
        !            41:   // unlink the file  
        !            42:   unlink($dest_filename);
        !            43: }
        !            44: 
        !            45: // clean the temp dir and file
        !            46: rmdir("$file_path/rename_variation"); 
        !            47: 
        !            48: echo "Done\n";
        !            49: ?>
        !            50: --EXPECTF--
        !            51: *** Testing rename() : rename files across directories ***
        !            52: -- Iteration 1 --
        !            53: bool(true)
        !            54: bool(false)
        !            55: bool(true)
        !            56: -- Iteration 2 --
        !            57: 
        !            58: Warning: rename(%s,%s): Not a directory in %s on line %d
        !            59: bool(false)
        !            60: bool(false)
        !            61: bool(false)
        !            62: 
        !            63: Warning: unlink(%s): No such file or directory in %s on line %d
        !            64: -- Iteration 3 --
        !            65: bool(true)
        !            66: bool(false)
        !            67: bool(true)
        !            68: -- Iteration 4 --
        !            69: bool(true)
        !            70: bool(false)
        !            71: bool(true)
        !            72: Done

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