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