Annotation of embedaddon/php/ext/standard/tests/dir/readdir_variation2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test readdir() function : usage variations - empty 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 readdir() a directory handle pointing to an empty directory to test behaviour
! 12: */
! 13:
! 14: echo "*** Testing readdir() : usage variations ***\n";
! 15:
! 16: $path = dirname(__FILE__) . '/readdir_variation2';
! 17: mkdir($path);
! 18: $dir_handle = opendir($path);
! 19:
! 20: echo "\n-- Pass an empty directory to readdir() --\n";
! 21: function mysort($a,$b) {
! 22: return strlen($a) > strlen($b) ? 1 : -1;
! 23: }
! 24: $entries = array();
! 25: while(FALSE !== ($file = readdir($dir_handle))){
! 26: $entries[] = $file;
! 27: }
! 28:
! 29: closedir($dir_handle);
! 30:
! 31: usort($entries, "mysort");
! 32: foreach($entries as $entry) {
! 33: var_dump($entry);
! 34: }
! 35: ?>
! 36: ===DONE===
! 37: --CLEAN--
! 38: <?php
! 39: $path = dirname(__FILE__) . '/readdir_variation2';
! 40: rmdir($path);
! 41: ?>
! 42: --EXPECTF--
! 43: *** Testing readdir() : usage variations ***
! 44:
! 45: -- Pass an empty directory to readdir() --
! 46: string(1) "."
! 47: string(2) ".."
! 48: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>