Skip to content

Commit

Permalink
[Finder] Fixed randomly failing tests due to the order files are read…
Browse files Browse the repository at this point in the history
… from the filesystem
  • Loading branch information
Brandon Turner authored and fabpot committed Sep 3, 2010
1 parent 1719bfb commit 26e4b2e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/Symfony/Tests/Component/Finder/FinderTest.php
Expand Up @@ -205,14 +205,21 @@ public function testGetIterator()
$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)
Expand Down

0 comments on commit 26e4b2e

Please sign in to comment.