/** * @group disconnected */ public function testIterationRewindable() { $client = $this->getMock('Predis\\Client', array('getProfile', 'hscan')); $client->expects($this->any())->method('getProfile')->will($this->returnValue(ServerProfile::get('2.8'))); $client->expects($this->exactly(2))->method('hscan')->with('key:hash', 0, array())->will($this->returnValue(array(0, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')))); $iterator = new HashKey($client, 'key:hash'); $iterator->rewind(); $this->assertTrue($iterator->valid()); $this->assertSame('value:1st', $iterator->current()); $this->assertSame('field:1st', $iterator->key()); $iterator->rewind(); $this->assertTrue($iterator->valid()); $this->assertSame('value:1st', $iterator->current()); $this->assertSame('field:1st', $iterator->key()); $iterator->next(); $this->assertTrue($iterator->valid()); $this->assertSame('value:2nd', $iterator->current()); $this->assertSame('field:2nd', $iterator->key()); $iterator->next(); $this->assertFalse($iterator->valid()); }