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

1.1     ! misho       1: --TEST--
        !             2: Test dir() function : basic functionality
        !             3: --FILE--
        !             4: <?php
        !             5: /* 
        !             6:  * Prototype  : object dir(string $directory[, resource $context])
        !             7:  * Description: Directory class with properties, handle and class and methods read, rewind and close
        !             8:  * Source code: ext/standard/dir.c
        !             9:  */
        !            10: 
        !            11: echo "*** Testing dir() : basic functionality ***\n";
        !            12: 
        !            13: // include the file.inc for Function: function create_files()
        !            14: include(dirname(__FILE__)."/../file/file.inc");
        !            15: 
        !            16: // create the temporary directory
        !            17: $file_path = dirname(__FILE__);
        !            18: $dir_path = $file_path."/dir_basic";
        !            19: @mkdir($dir_path);
        !            20: 
        !            21: // create files within the temporary directory
        !            22: create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "dir_basic");
        !            23: 
        !            24: echo "Get Directory instance:\n";
        !            25: $d = dir($dir_path);
        !            26: var_dump( $d );
        !            27: 
        !            28: echo "\nRead and rewind:\n";
        !            29: var_dump( $d->read() );
        !            30: var_dump( $d->read() );
        !            31: var_dump( $d->rewind() );
        !            32: 
        !            33: echo "\nTest using handle directly:\n";
        !            34: var_dump( readdir($d->handle) );
        !            35: var_dump( readdir($d->handle) );
        !            36: 
        !            37: echo "\nClose directory:\n";
        !            38: var_dump( $d->close() );
        !            39: var_dump( $d );
        !            40: 
        !            41: echo "\nTest read after closing the dir:";
        !            42: var_dump( $d->read() );
        !            43: 
        !            44: // delete temp files
        !            45: delete_files($dir_path, 3, "dir_basic", 1, ".tmp");
        !            46: echo "Done";
        !            47: ?>
        !            48: --CLEAN--
        !            49: <?php
        !            50: $file_path = dirname(__FILE__);
        !            51: $dir_path = $file_path."/dir_basic";
        !            52: 
        !            53: rmdir($dir_path);
        !            54: ?>
        !            55: --EXPECTF--
        !            56: *** Testing dir() : basic functionality ***
        !            57: Get Directory instance:
        !            58: object(Directory)#%d (2) {
        !            59:   ["path"]=>
        !            60:   string(%d) "%s/dir_basic"
        !            61:   ["handle"]=>
        !            62:   resource(%d) of type (stream)
        !            63: }
        !            64: 
        !            65: Read and rewind:
        !            66: string(%d) "%s"
        !            67: string(%d) "%s"
        !            68: NULL
        !            69: 
        !            70: Test using handle directly:
        !            71: string(%d) "%s"
        !            72: string(%d) "%s"
        !            73: 
        !            74: Close directory:
        !            75: NULL
        !            76: object(Directory)#%d (2) {
        !            77:   ["path"]=>
        !            78:   string(%d) "%s/dir_basic"
        !            79:   ["handle"]=>
        !            80:   resource(%d) of type (Unknown)
        !            81: }
        !            82: 
        !            83: Test read after closing the dir:
        !            84: Warning: Directory::read(): %d is not a valid Directory resource in %s on line %d
        !            85: bool(false)
        !            86: Done

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