Annotation of embedaddon/php/ext/standard/tests/dir/readdir_variation3.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test readdir() function : usage variations - sub-directories 
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : string readdir([resource $dir_handle])
        !             6:  * Description: Read directory entry from dir_handle 
        !             7:  * Source code: ext/standard/dir.c
        !             8:  */
        !             9: 
        !            10: /*
        !            11:  * Pass a directory handle pointing to a directory that has a sub-directory
        !            12:  * to test behaviour of readdir()
        !            13:  */
        !            14: 
        !            15: echo "*** Testing readdir() : usage variations ***\n";
        !            16: 
        !            17: // include the file.inc for Function: function create_files()
        !            18: chdir(dirname(__FILE__));
        !            19: include(dirname(__FILE__)."/../file/file.inc");
        !            20: 
        !            21: $path_top = dirname(__FILE__) . '/readdir_variation3';
        !            22: $path_sub = $path_top . '/sub_folder';
        !            23: mkdir($path_top);
        !            24: mkdir($path_sub);
        !            25: 
        !            26: create_files($path_top, 2);
        !            27: create_files($path_sub, 2);
        !            28: 
        !            29: $dir_handle = opendir($path_top);
        !            30: while(FALSE !== ($file = readdir($dir_handle))) {
        !            31:        
        !            32:        // different OS order files differently so will
        !            33:        // store file names into an array so can use sorted in expected output
        !            34:        $contents[] = $file;
        !            35: }
        !            36: 
        !            37: // more important to check that all contents are present than order they are returned in
        !            38: sort($contents);
        !            39: var_dump($contents);
        !            40: 
        !            41: delete_files($path_top, 2);
        !            42: delete_files($path_sub, 2);
        !            43: 
        !            44: closedir($dir_handle);
        !            45: ?>
        !            46: ===DONE===
        !            47: --CLEAN--
        !            48: <?php
        !            49: $path_top = dirname(__FILE__) . '/readdir_variation3';
        !            50: $path_sub = $path_top . '/sub_folder';
        !            51: rmdir($path_sub);
        !            52: rmdir($path_top);
        !            53: ?>
        !            54: --EXPECTF--
        !            55: *** Testing readdir() : usage variations ***
        !            56: array(5) {
        !            57:   [0]=>
        !            58:   string(1) "."
        !            59:   [1]=>
        !            60:   string(2) ".."
        !            61:   [2]=>
        !            62:   string(9) "file1.tmp"
        !            63:   [3]=>
        !            64:   string(9) "file2.tmp"
        !            65:   [4]=>
        !            66:   string(10) "sub_folder"
        !            67: }
        !            68: ===DONE===

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