public function testIterationMethods() { $results = array(array('_id' => 1, 'x' => 'foo'), array('_id' => 2, 'x' => 'bar')); $cursor = $this->getMockCursor(); $cursor->expects($this->once())->method('toArray')->will($this->returnValue($results)); $eagerCursor = new EagerCursor($cursor); $this->assertFalse($eagerCursor->isInitialized()); foreach (range(1, 2) as $_) { $this->assertEquals(0, $eagerCursor->key()); $this->assertTrue($eagerCursor->isInitialized()); $this->assertEquals($results[0], $eagerCursor->current()); $eagerCursor->next(); $this->assertEquals(1, $eagerCursor->key()); $this->assertEquals($results[1], $eagerCursor->current()); $eagerCursor->next(); $this->assertFalse($eagerCursor->valid()); $eagerCursor->rewind(); } }