Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/TestRedis.php')
-rw-r--r--tests/TestRedis.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/TestRedis.php b/tests/TestRedis.php
index 20fdb358..70d38355 100644
--- a/tests/TestRedis.php
+++ b/tests/TestRedis.php
@@ -1974,11 +1974,33 @@ class Redis_Test extends TestSuite
$this->assertTrue($this->redis->zunion('key3', array('key1', 'key2'), array(2, 3.0)) === 3);
-
$this->redis->delete('key1');
$this->redis->delete('key2');
$this->redis->delete('key3');
+ // Test 'inf', '-inf', and '+inf' weights (GitHub issue #336)
+ $this->redis->zadd('key1', 1, 'one', 2, 'two', 3, 'three');
+ $this->redis->zadd('key2', 3, 'three', 4, 'four', 5, 'five');
+
+ // Make sure phpredis handles these weights
+ $this->assertTrue($this->redis->zunion('key3', array('key1','key2'), array(1, 'inf')) === 5);
+ $this->assertTrue($this->redis->zunion('key3', array('key1','key2'), array(1, '-inf')) === 5);
+ $this->assertTrue($this->redis->zunion('key3', array('key1','key2'), array(1, '+inf')) === 5);
+
+ // Now, confirm that they're being sent, and that it works
+ $arr_weights = Array('inf','-inf','+inf');
+
+ foreach($arr_weights as $str_weight) {
+ $r = $this->redis->zunionstore('key3', array('key1','key2'), array(1,$str_weight));
+ $this->assertTrue($r===5);
+ $r = $this->redis->zrangebyscore('key3', '(-inf', '(inf',array('withscores'=>true));
+ $this->assertTrue(count($r)===2);
+ $this->assertTrue(isset($r['one']));
+ $this->assertTrue(isset($r['two']));
+ }
+
+ $this->redis->del('key1','key2','key3');
+
$this->redis->zadd('key1', 2000.1, 'one');
$this->redis->zadd('key1', 3000.1, 'two');
$this->redis->zadd('key1', 4000.1, 'three');