1--TEST--
2SPL: DirectoryIterator::getExtension() basic test
3--FILE--
4<?php
5$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
6
7if (!mkdir($dir)) {
8    die('Failed to create test directory');
9}
10
11$files = array('test.txt', 'test.extension', 'test');
12foreach ($files as $file) {
13    touch($dir . $file);
14}
15
16$dit_exts = array();
17$nfo_exts = array();
18
19foreach (new DirectoryIterator($dir) as $file) {
20    if ($file->isDot()) {
21        continue;
22    }
23
24    $dit_exts[] = $file->getExtension();
25    $nfo_exts[] = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
26}
27var_dump($dit_exts === $nfo_exts);
28sort($dit_exts);
29var_dump($dit_exts);
30?>
31--CLEAN--
32<?php
33$dir   = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
34$files = array('test.txt', 'test.extension', 'test');
35foreach ($files as $file) {
36    unlink($dir . $file);
37}
38rmdir($dir);
39?>
40--EXPECT--
41bool(true)
42array(3) {
43  [0]=>
44  string(0) ""
45  [1]=>
46  string(9) "extension"
47  [2]=>
48  string(3) "txt"
49}
50