1--TEST--
2Test rewinddir() function : usage variations - file pointers
3--FILE--
4<?php
5/*
6 * Pass a file pointer to rewinddir() to test behaviour
7 */
8
9echo "*** Testing rewinddir() : usage variations ***\n";
10
11echo "\n-- Open a file using fopen --\n";
12var_dump($fp = fopen(__FILE__, 'r'));
13
14$result1 = fread($fp, 5);
15
16try {
17    var_dump(rewinddir($fp));
18} catch (\TypeError $e) {
19    echo $e->getMessage() . "\n";
20}
21$result2 = fread($fp, 5);
22
23echo "\n-- Check if rewinddir() has repositioned the file pointer --\n";
24if ($result1 === $result2) {
25    echo "rewinddir() works on file pointers\n";
26} else {
27    echo "rewinddir() does not work on file pointers\n";
28}
29?>
30--EXPECTF--
31*** Testing rewinddir() : usage variations ***
32
33-- Open a file using fopen --
34resource(%d) of type (stream)
35rewinddir(): Argument #1 ($dir_handle) must be a valid Directory resource
36
37-- Check if rewinddir() has repositioned the file pointer --
38rewinddir() does not work on file pointers
39