xref: /php-src/ext/spl/tests/dit_002.phpt (revision f8d79582)
1--TEST--
2SPL: DirectoryIterator defaults
3--SKIPIF--
4<?php if (!defined('GLOB_ERR')) die('skip GLOB_ERR not defined'); ?>
5--FILE--
6<?php
7
8$classes = array(
9    'DirectoryIterator' => 0,
10    'FilesystemIterator' => 1,
11    'RecursiveDirectoryIterator' => 1,
12    'GlobIterator' => 1,
13);
14
15foreach ($classes as $class => $flags) {
16    echo "===$class===\n";
17    $ref = new ReflectionClass($class);
18    $obj = $ref->newInstance('glob://*');
19    echo get_class($obj->current()) . "\n";
20    if ($flags)
21    {
22        var_dump($obj->getFlags());
23        $flags = array(
24            FilesystemIterator::CURRENT_AS_FILEINFO => 0,
25            FilesystemIterator::CURRENT_AS_SELF     => 0,
26            FilesystemIterator::CURRENT_AS_PATHNAME => 1,
27        );
28        foreach($flags as $flag => $isstring) {
29            $obj->setFlags($flag);
30            $obj->rewind();
31            var_dump($obj->getFlags());
32            if ($isstring) {
33                $val = $obj->current();
34                if (is_string($val)) {
35                    var_dump(true);
36                } else {
37                    var_dump($val);
38                }
39            } else {
40                echo get_class($obj->current()) . "\n";
41            }
42        }
43    }
44}
45?>
46--EXPECTF--
47===DirectoryIterator===
48DirectoryIterator
49===FilesystemIterator===
50SplFileInfo
51int(%d)
52int(0)
53SplFileInfo
54int(16)
55FilesystemIterator
56int(32)
57bool(true)
58===RecursiveDirectoryIterator===
59SplFileInfo
60int(0)
61int(0)
62SplFileInfo
63int(16)
64RecursiveDirectoryIterator
65int(32)
66bool(true)
67===GlobIterator===
68SplFileInfo
69int(0)
70int(0)
71SplFileInfo
72int(16)
73GlobIterator
74int(32)
75bool(true)
76