diff options
author | Marin Bezhanov <marin.bezhanov@gmail.com> | 2019-02-17 14:05:58 +0300 |
---|---|---|
committer | Marin Bezhanov <marin.bezhanov@gmail.com> | 2019-02-17 14:05:58 +0300 |
commit | 46f035615ecaf839cfe515dac39f209d50689461 (patch) | |
tree | 977e69e8f4e3e8043757c4204f9a1addf2d2c89a /tests | |
parent | 22d81a94eee2ea613fc515e1d714b73142d46241 (diff) |
Add ZPOPMAX and ZPOPMIN support
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RedisTest.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php index 75fade20..e666b1fc 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -2409,6 +2409,29 @@ class Redis_Test extends TestSuite $this->assertEquals($this->redis->zRemRangeByLex('key', '[a', '[c'), 2); } + public function testZPop() { + if (version_compare($this->version, "5.0.0", "lt")) { + $this->MarkTestSkipped(); + return; + } + + // zPopMax and zPopMin without a COUNT argument + $this->redis->del('key'); + $this->redis->zAdd('key', 0, 'a', 1, 'b', 2, 'c', 3, 'd', 4, 'e'); + $this->assertTrue(array('e', '4') === $this->redis->zPopMax('key')); + $this->assertTrue(array('a', '0') === $this->redis->zPopMin('key')); + + // zPopMax with a COUNT argument + $this->redis->del('key'); + $this->redis->zAdd('key', 0, 'a', 1, 'b', 2, 'c', 3, 'd', 4, 'e'); + $this->assertTrue(array('e', '4', 'd', '3', 'c', '2') === $this->redis->zPopMax('key', 3)); + + // zPopMin with a COUNT argument + $this->redis->del('key'); + $this->redis->zAdd('key', 0, 'a', 1, 'b', 2, 'c', 3, 'd', 4, 'e'); + $this->assertTrue(array('a', '0', 'b', '1', 'c', '2') === $this->redis->zPopMin('key', 3)); + } + public function testHashes() { $this->redis->del('h', 'key'); $this->assertTrue(0 === $this->redis->hLen('h')); |