/**
* @group disconnected
*/
public function testIterationRewindable()
{
$client = $this->getMock('Predis\\Client', array('getProfile', 'lrange'));
$client->expects($this->any())->method('getProfile')->will($this->returnValue(ServerProfile::getDefault()));
$client->expects($this->exactly(2))->method('lrange')->with('key:list', 0, 9)->will($this->returnValue(array('item:1', 'item:2')));
$iterator = new ListKey($client, 'key:list');
$iterator->rewind();
$this->assertTrue($iterator->valid());
$this->assertSame('item:1', $iterator->current());
$this->assertSame(0, $iterator->key());
$iterator->rewind();
$this->assertTrue($iterator->valid());
$this->assertSame('item:1', $iterator->current());
$this->assertSame(0, $iterator->key());
$iterator->next();
$this->assertTrue($iterator->valid());
$this->assertSame(1, $iterator->key());
$this->assertSame('item:2', $iterator->current());
$iterator->next();
$this->assertFalse($iterator->valid());
}