Author: Daniele Alessandri (suppakilla@gmail.com)
Inheritance: extends CursorBasedIterator
Exemple #1
0
 /**
  * @group disconnected
  */
 public function testIterationRewindable()
 {
     $client = $this->getMock('Predis\\Client', array('getProfile', 'zscan'));
     $client->expects($this->any())->method('getProfile')->will($this->returnValue(ServerProfile::get('2.8')));
     $client->expects($this->exactly(2))->method('zscan')->with('key:zset', 0, array())->will($this->returnValue(array(0, array(array('member:1st', 1.0), array('member:2nd', 2.0)))));
     $iterator = new SortedSetKey($client, 'key:zset');
     $iterator->rewind();
     $this->assertTrue($iterator->valid());
     $this->assertSame(1.0, $iterator->current());
     $this->assertSame('member:1st', $iterator->key());
     $iterator->rewind();
     $this->assertTrue($iterator->valid());
     $this->assertSame(1.0, $iterator->current());
     $this->assertSame('member:1st', $iterator->key());
     $iterator->next();
     $this->assertTrue($iterator->valid());
     $this->assertSame(2.0, $iterator->current());
     $this->assertSame('member:2nd', $iterator->key());
     $iterator->next();
     $this->assertFalse($iterator->valid());
 }