Skip to content

Commit 0535872

Browse files
committed
Use separate directory in dit_004.phpt
Make sure the directory is not modified while we're iterating it, which may give unstable results.
1 parent 1c868b1 commit 0535872

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ext/spl/tests/dit_004.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
SPL: DirectoryIterator and clone
33
--FILE--
44
<?php
5-
$a = new DirectoryIterator(__DIR__);
5+
6+
@mkdir($dir = __DIR__ . '/dit_004');
7+
touch($dir . '/file1');
8+
touch($dir . '/file2');
9+
touch($dir . '/file3');
10+
11+
$a = new DirectoryIterator($dir);
612
$b = clone $a;
713
var_dump((string)$b == (string)$a);
814
var_dump($a->key(), $b->key());
@@ -13,6 +19,14 @@ $c = clone $a;
1319
var_dump((string)$c == (string)$a);
1420
var_dump($a->key(), $c->key());
1521
?>
22+
--CLEAN--
23+
<?php
24+
$dir = __DIR__ . '/dit_004';
25+
unlink($dir . '/file1');
26+
unlink($dir . '/file2');
27+
unlink($dir . '/file3');
28+
rmdir($dir);
29+
?>
1630
--EXPECT--
1731
bool(true)
1832
int(0)

0 commit comments

Comments
 (0)