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