public function testSortedSets() { $this->assertEquals(1, $this->credis->zAdd('myset', 1, 'Hello')); $this->assertEquals(1, $this->credis->zAdd('myset', 2.123, 'World')); $this->assertEquals(1, $this->credis->zAdd('myset', 10, 'And')); $this->assertEquals(1, $this->credis->zAdd('myset', 11, 'Goodbye')); $this->assertEquals(4, count($this->credis->zRangeByScore('myset', '-inf', '+inf'))); $this->assertEquals(2, count($this->credis->zRangeByScore('myset', '1', '9'))); $range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('limit' => array(1, 2))); $this->assertEquals(2, count($range)); $this->assertEquals('World', $range[0]); $this->assertEquals('And', $range[1]); $range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('withscores' => true, 'limit' => array(1, 2))); $this->assertEquals(2, count($range)); $this->assertTrue(array_key_exists('World', $range)); $this->assertEquals(2.123, $range['World']); $this->assertTrue(array_key_exists('And', $range)); $this->assertEquals(10, $range['And']); $range = $this->credis->zRangeByScore('myset', 10, '+inf', array('withscores' => true)); $this->assertEquals(2, count($range)); $this->assertTrue(array_key_exists('And', $range)); $this->assertEquals(10, $range['And']); $this->assertTrue(array_key_exists('Goodbye', $range)); $this->assertEquals(11, $range['Goodbye']); // withscores-option is off $range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('withscores')); $this->assertEquals(4, count($range)); $this->assertEquals(range(0, 3), array_keys($range)); // expecting numeric array without scores $range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('withscores' => false)); $this->assertEquals(4, count($range)); $this->assertEquals(range(0, 3), array_keys($range)); }