[Finder] Fixed randomly failing tests due to the order files are read from the filesystem

This commit is contained in:
Brandon Turner 2010-08-12 10:25:53 -05:00 committed by Fabien Potencier
parent 1719bfb871
commit 26e4b2e2ef

View File

@ -205,14 +205,21 @@ class FinderTest extends Iterator\RealIteratorTestCase
$dirs[] = (string) $dir;
}
$this->assertEquals($this->toAbsolute(array('foo', 'toto')), $dirs, 'implements the \IteratorAggregate interface');
$expected = $this->toAbsolute(array('foo', 'toto'));
sort($dirs);
sort($expected);
$this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
$finder = new Finder();
$this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
$finder = new Finder();
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
$this->assertEquals($this->toAbsolute(array('foo', 'toto')), array_values(array_map(function ($a) { return (string) $a; }, $a)), 'implements the \IteratorAggregate interface');
$a = array_values(array_map(function ($a) { return (string) $a; }, $a));
sort($a);
$this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
}
protected function toAbsolute($files)