Skip to content

Commit f65b5e2

Browse files
authored
Merge pull request phpredis#1285 from ndxbn/test-zset
add test for zRangeByLex method
2 parents 6e00f22 + a99c450 commit f65b5e2

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/RedisTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,20 @@ public function testZX() {
22882288
$this->assertTrue(0 === $this->redis->zRevRank('z', 'five'));
22892289
}
22902290

2291+
public function testZRangeByLex() {
2292+
$this->redis->del('key');
2293+
foreach(range('a', 'g') as $c) {
2294+
$this->redis->zAdd('key', 0, $c);
2295+
}
2296+
2297+
$this->assertEquals($this->redis->zRangeByLex('key', '-', '[c'), Array('a', 'b', 'c'));
2298+
$this->assertEquals($this->redis->zRangeByLex('key', '(e', '+'), Array('f', 'g'));
2299+
2300+
// with limit offset
2301+
$this->assertEquals($this->redis->zRangeByLex('key', '-', '[c', 1, 2), Array('b', 'c') );
2302+
$this->assertEquals($this->redis->zRangeByLex('key', '-', '(c', 1, 2), Array('b'));
2303+
}
2304+
22912305
public function testHashes() {
22922306
$this->redis->del('h', 'key');
22932307
$this->assertTrue(0 === $this->redis->hLen('h'));

0 commit comments

Comments
 (0)