@@ -1974,11 +1974,33 @@ public function testZX() {
1974
1974
1975
1975
$ this ->assertTrue ($ this ->redis ->zunion ('key3 ' , array ('key1 ' , 'key2 ' ), array (2 , 3.0 )) === 3 );
1976
1976
1977
-
1978
1977
$ this ->redis ->delete ('key1 ' );
1979
1978
$ this ->redis ->delete ('key2 ' );
1980
1979
$ this ->redis ->delete ('key3 ' );
1981
1980
1981
+ // Test 'inf', '-inf', and '+inf' weights (GitHub issue #336)
1982
+ $ this ->redis ->zadd ('key1 ' , 1 , 'one ' , 2 , 'two ' , 3 , 'three ' );
1983
+ $ this ->redis ->zadd ('key2 ' , 3 , 'three ' , 4 , 'four ' , 5 , 'five ' );
1984
+
1985
+ // Make sure phpredis handles these weights
1986
+ $ this ->assertTrue ($ this ->redis ->zunion ('key3 ' , array ('key1 ' ,'key2 ' ), array (1 , 'inf ' )) === 5 );
1987
+ $ this ->assertTrue ($ this ->redis ->zunion ('key3 ' , array ('key1 ' ,'key2 ' ), array (1 , '-inf ' )) === 5 );
1988
+ $ this ->assertTrue ($ this ->redis ->zunion ('key3 ' , array ('key1 '
A9A3
span>,'key2 ' ), array (1 , '+inf ' )) === 5 );
1989
+
1990
+ // Now, confirm that they're being sent, and that it works
1991
+ $ arr_weights = Array ('inf ' ,'-inf ' ,'+inf ' );
1992
+
1993
+ foreach ($ arr_weights as $ str_weight ) {
1994
+ $ r = $ this ->redis ->zunionstore ('key3 ' , array ('key1 ' ,'key2 ' ), array (1 ,$ str_weight ));
1995
+ $ this ->assertTrue ($ r ===5 );
1996
+ $ r = $ this ->redis ->zrangebyscore ('key3 ' , '(-inf ' , '(inf ' ,array ('withscores ' =>true ));
1997
+ $ this ->assertTrue (count ($ r )===2 );
1998
+ $ this ->assertTrue (isset ($ r ['one ' ]));
1999
+ $ this ->assertTrue (isset ($ r ['two ' ]));
2000
+ }
2001
+
2002
+ $ this ->redis ->del ('key1 ' ,'key2 ' ,'key3 ' );
2003
+
1982
2004
$ this ->redis ->zadd ('key1 ' , 2000.1 , 'one ' );
1983
2005
$ this ->redis ->zadd ('key1 ' , 3000.1 , 'two ' );
1984
2006
$ this ->redis ->zadd ('key1 ' , 4000.1 , 'three ' );
0 commit comments