Annotation of embedaddon/php/ext/standard/tests/dir/rewinddir_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test rewinddir() function : basic functionality
3: --FILE--
4: <?php
5: /* Prototype : void rewinddir([resource $dir_handle])
6: * Description: Rewind dir_handle back to the start
7: * Source code: ext/standard/dir.c
8: * Alias to functions: rewind
9: */
10:
11: /*
12: * Test basic functionality of rewinddir()
13: */
14:
15: echo "*** Testing rewinddir() : basic functionality ***\n";
16:
17: // include file.inc for create_files function
18: include(dirname(__FILE__) . "/../file/file.inc");
19:
20: $dir_path1 = dirname(__FILE__) . "/rewinddir_basic_dir1";
21: $dir_path2 = dirname(__FILE__) . "/rewinddir_basic_dir2";
22: mkdir($dir_path1);
23: mkdir($dir_path2);
24:
25: @create_files($dir_path1, 1);
26: @create_files($dir_path2, 1, 'numeric', 0755, 1, 'w', 'file', 2);
27: var_dump($dh1 = opendir($dir_path1));
28: var_dump($dh2 = opendir($dir_path2));
29:
30: $data = array();
31: echo "\n-- Read and rewind first directory (argument supplied) --\n";
32: while(FALSE !== $file1 = readdir($dh1)) {
33: $data[] = $file1;
34: }
35: $first = $data[0];
36: sort($data);
37: var_dump($data);
38:
39: var_dump(rewinddir($dh1));
40: var_dump(readdir($dh1) == $first);
41:
42: $data = array();
43: echo "\n-- Read and rewind second directory (no argument supplied) --\n";
44: while(FALSE !== $file2 = readdir()) {
45: $data[] = $file2;
46: }
47: $first = $data[0];
48: sort($data);
49: var_dump($data);
50:
51: var_dump(rewinddir());
52: var_dump(readdir() == $first);
53:
54: closedir($dh1);
55: closedir($dh2);
56:
57: delete_files($dir_path1, 1);
58: delete_files($dir_path2, 1, 'file', 2);
59: ?>
60: ===DONE===
61: --CLEAN--
62: <?php
63: $dir_path1 = dirname(__FILE__) . "/rewinddir_basic_dir1";
64: $dir_path2 = dirname(__FILE__) . "/rewinddir_basic_dir2";
65: rmdir($dir_path1);
66: rmdir($dir_path2);
67: ?>
68: --EXPECTF--
69: *** Testing rewinddir() : basic functionality ***
70: resource(%d) of type (stream)
71: resource(%d) of type (stream)
72:
73: -- Read and rewind first directory (argument supplied) --
74: array(3) {
75: [0]=>
76: string(1) "."
77: [1]=>
78: string(2) ".."
79: [2]=>
80: string(9) "file1.tmp"
81: }
82: NULL
83: bool(true)
84:
85: -- Read and rewind second directory (no argument supplied) --
86: array(3) {
87: [0]=>
88: string(1) "."
89: [1]=>
90: string(2) ".."
91: [2]=>
92: string(9) "file2.tmp"
93: }
94: NULL
95: bool(true)
96: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>