xref: /PHP-5.5/ext/spl/tests/bug66405.phpt (revision a0c03a3e)
1--TEST--
2SPL: RecursiveDirectoryIterator with CURRENT_AS_PATHNAME flag
3--CREDITS--
4Paul Garvin pgarvin76@gmail.com
5--FILE--
6<?php
7$td = __DIR__ . '/bug66405';
8mkdir($td);
9touch($td . '/file1.txt');
10touch($td . '/file2.md');
11mkdir($td . '/testsubdir');
12touch($td . '/testsubdir/file3.csv');
13
14class Bug66405 extends RecursiveDirectoryIterator
15{
16    public function current()
17    {
18        $current = parent::current();
19        echo gettype($current) . " $current\n";
20        return $current;
21    }
22
23    public function getChildren()
24    {
25        $children = parent::getChildren();
26        if (is_object($children)) {
27            echo get_class($children) . " $children\n";
28        } else {
29            echo gettype($children) . " $children\n";
30        }
31        return $children;
32    }
33}
34
35$rdi = new Bug66405($td, FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS);
36$rii = new RecursiveIteratorIterator($rdi);
37
38ob_start();
39foreach ($rii as $file) {
40    //noop
41}
42$results = explode("\n", ob_get_clean());
43sort($results);
44echo implode("\n", $results);
45?>
46--CLEAN--
47<?php
48$td = __DIR__ . '/bug66405';
49unlink($td . '/testsubdir/file3.csv');
50unlink($td . '/file2.md');
51unlink($td . '/file1.txt');
52rmdir($td . '/testsubdir');
53rmdir($td);
54?>
55--EXPECTF--
56Bug66405 file3.csv
57string %sbug66405%efile1.txt
58string %sbug66405%efile2.md
59string %sbug66405%etestsubdir%efile3.csv
60