1--TEST--
2Test scandir() function : usage variations - different sorting constants
3--FILE--
4<?php
5printf("SCANDIR_SORT_ASCENDING: %d\n", SCANDIR_SORT_ASCENDING);
6printf("SCANDIR_SORT_DESCENDING: %d\n", SCANDIR_SORT_DESCENDING);
7printf("SCANDIR_SORT_NONE: %d\n", SCANDIR_SORT_NONE);
8
9/*
10 * Pass different integers as $sorting_order argument to test how scandir()
11 * re-orders the array
12 */
13
14echo "*** Testing scandir() : usage variations ***\n";
15
16// include for create_files/delete_files functions
17include(__DIR__ . '/../file/file.inc');
18
19// create directory and files
20$dir = __DIR__ . '/scandir_variation10';
21mkdir($dir);
22@create_files($dir, 2);
23
24// Deterministic tests.
25var_dump(scandir($dir, SCANDIR_SORT_ASCENDING));
26var_dump(scandir($dir, SCANDIR_SORT_DESCENDING));
27
28// Non-deterministic tests.
29$files = scandir($dir, SCANDIR_SORT_NONE);
30var_dump(count($files));
31var_dump(in_array('.', $files));
32var_dump(in_array('..', $files));
33var_dump(in_array('file1.tmp', $files));
34var_dump(in_array('file2.tmp', $files));
35
36delete_files($dir, 2);
37?>
38--CLEAN--
39<?php
40$dir = __DIR__ . '/scandir_variation10';
41rmdir($dir);
42?>
43--EXPECT--
44SCANDIR_SORT_ASCENDING: 0
45SCANDIR_SORT_DESCENDING: 1
46SCANDIR_SORT_NONE: 2
47*** Testing scandir() : usage variations ***
48array(4) {
49  [0]=>
50  string(1) "."
51  [1]=>
52  string(2) ".."
53  [2]=>
54  string(9) "file1.tmp"
55  [3]=>
56  string(9) "file2.tmp"
57}
58array(4) {
59  [0]=>
60  string(9) "file2.tmp"
61  [1]=>
62  string(9) "file1.tmp"
63  [2]=>
64  string(2) ".."
65  [3]=>
66  string(1) "."
67}
68int(4)
69bool(true)
70bool(true)
71bool(true)
72bool(true)
73