public function testGetIterator() { $finder = new Finder(); try { $finder->getIterator(); $this->fail('->getIterator() throws a \\LogicException if the in() method has not been called'); } catch (\Exception $e) { $this->assertInstanceOf('LogicException', $e, '->getIterator() throws a \\LogicException if the in() method has not been called'); } $finder = new Finder(); $dirs = array(); foreach ($finder->directories()->in(self::$tmpDir) as $dir) { $dirs[] = (string) $dir; } $this->assertEquals($this->toAbsolute(array('foo', 'toto')), $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'); }