You are here

public function FinderTest::testGetIterator in Database Sanitize 7

File

vendor/symfony/finder/Tests/FinderTest.php, line 334

Class

FinderTest

Namespace

Symfony\Component\Finder\Tests

Code

public function testGetIterator() {
  $finder = $this
    ->buildFinder();
  $dirs = array();
  foreach ($finder
    ->directories()
    ->in(self::$tmpDir) as $dir) {
    $dirs[] = (string) $dir;
  }
  $expected = $this
    ->toAbsolute(array(
    'foo',
    'toto',
  ));
  sort($dirs);
  sort($expected);
  $this
    ->assertEquals($expected, $dirs, 'implements the \\IteratorAggregate interface');
  $finder = $this
    ->buildFinder();
  $this
    ->assertEquals(2, iterator_count($finder
    ->directories()
    ->in(self::$tmpDir)), 'implements the \\IteratorAggregate interface');
  $finder = $this
    ->buildFinder();
  $a = iterator_to_array($finder
    ->directories()
    ->in(self::$tmpDir));
  $a = array_values(array_map('strval', $a));
  sort($a);
  $this
    ->assertEquals($expected, $a, 'implements the \\IteratorAggregate interface');
}