Annotation of embedaddon/php/ext/standard/tests/dir/scandir_variation10.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test scandir() function : usage variations - different sorting constants
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
! 6: * Description: List files & directories inside the specified path
! 7: * Source code: ext/standard/dir.c
! 8: */
! 9:
! 10: printf("SCANDIR_SORT_ASCENDING: %d\n", SCANDIR_SORT_ASCENDING);
! 11: printf("SCANDIR_SORT_DESCENDING: %d\n", SCANDIR_SORT_DESCENDING);
! 12: printf("SCANDIR_SORT_NONE: %d\n", SCANDIR_SORT_NONE);
! 13:
! 14: /*
! 15: * Pass different integers as $sorting_order argument to test how scandir()
! 16: * re-orders the array
! 17: */
! 18:
! 19: echo "*** Testing scandir() : usage variations ***\n";
! 20:
! 21: // include for create_files/delete_files functions
! 22: include(dirname(__FILE__) . '/../file/file.inc');
! 23:
! 24: // create directory and files
! 25: $dir = dirname(__FILE__) . '/scandir_variation10';
! 26: mkdir($dir);
! 27: @create_files($dir, 2);
! 28:
! 29: // Deterministic tests.
! 30: var_dump(scandir($dir, SCANDIR_SORT_ASCENDING));
! 31: var_dump(scandir($dir, SCANDIR_SORT_DESCENDING));
! 32:
! 33: // Non-deterministic tests.
! 34: $files = scandir($dir, SCANDIR_SORT_NONE);
! 35: var_dump(count($files));
! 36: var_dump(in_array('.', $files));
! 37: var_dump(in_array('..', $files));
! 38: var_dump(in_array('file1.tmp', $files));
! 39: var_dump(in_array('file2.tmp', $files));
! 40:
! 41: delete_files($dir, 2);
! 42: ?>
! 43: ===DONE===
! 44: --CLEAN--
! 45: <?php
! 46: $dir = dirname(__FILE__) . '/scandir_variation10';
! 47: rmdir($dir);
! 48: ?>
! 49: --EXPECTF--
! 50: SCANDIR_SORT_ASCENDING: 0
! 51: SCANDIR_SORT_DESCENDING: 1
! 52: SCANDIR_SORT_NONE: 2
! 53: *** Testing scandir() : usage variations ***
! 54: array(4) {
! 55: [0]=>
! 56: string(1) "."
! 57: [1]=>
! 58: string(2) ".."
! 59: [2]=>
! 60: string(9) "file1.tmp"
! 61: [3]=>
! 62: string(9) "file2.tmp"
! 63: }
! 64: array(4) {
! 65: [0]=>
! 66: string(9) "file2.tmp"
! 67: [1]=>
! 68: string(9) "file1.tmp"
! 69: [2]=>
! 70: string(2) ".."
! 71: [3]=>
! 72: string(1) "."
! 73: }
! 74: int(4)
! 75: bool(true)
! 76: bool(true)
! 77: bool(true)
! 78: bool(true)
! 79: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>