diff options
author | michael-grunder <michael.grunder@gmail.com> | 2019-02-24 04:41:19 +0300 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2019-02-24 04:41:19 +0300 |
commit | eb81b9153cb34c7342ae7a0c7f9cba7eadd54c88 (patch) | |
tree | 3ab97834c8a78b448aa719da5aab238e144cd78a /tests | |
parent | 85419ce7d370dca4d81e9426363ca0ae65c93439 (diff) | |
parent | 2ec7d91a7be50eac09567420e2a41e2f3f3f005c (diff) |
Merge branch 'issue-1509' into issue.1448-require_php7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RedisTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php index b9b65f53..81d49734 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -2409,6 +2409,51 @@ class Redis_Test extends TestSuite $this->assertEquals($this->redis->zRemRangeByLex('key', '[a', '[c'), 2); } + public function testBZPop() { + if (version_compare($this->version, "5.0.0", "lt")) { + $this->MarkTestSkipped(); + return; + } + + $this->redis->del('{zs}1', '{zs}2'); + $this->redis->zAdd('{zs}1', 0, 'a', 1, 'b', 2, 'c'); + $this->redis->zAdd('{zs}2', 3, 'A', 4, 'B', 5, 'D'); + + $this->assertEquals(Array('{zs}1', 'a', '0'), $this->redis->bzPopMin('{zs}1', '{zs}2', 0)); + $this->assertEquals(Array('{zs}1', 'c', '2'), $this->redis->bzPopMax(Array('{zs}1', '{zs}2'), 0)); + $this->assertEquals(Array('{zs}2', 'A', '3'), $this->redis->bzPopMin('{zs}2', '{zs}1', 0)); + + /* Verify timeout is being sent */ + $this->redis->del('{zs}1', '{zs}2'); + $st = microtime(true) * 1000; + $this->redis->bzPopMin('{zs}1', '{zs}2', 1); + $et = microtime(true) * 1000; + $this->assertTrue($et - $st > 100); + } + + 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.0) === $this->redis->zPopMax('key')); + $this->assertTrue(array('a' => 0.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.0, 'd' => 3.0, 'c' => 2.0) === $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.0, 'b' => 1.0, 'c' => 2.0) === $this->redis->zPopMin('key', 3)); + } + public function testHashes() { $this->redis->del('h', 'key'); $this->assertTrue(0 === $this->redis->hLen('h')); |