Skip to content

Commit d01abbb

Browse files
committed
Added tests for zUnion and zInter with aggregate functions but without weights
1 parent 6418410 commit d01abbb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/TestRedis.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,20 @@ public function testZX() {
19711971
$this->redis->delete('key2');
19721972
$this->redis->delete('key3');
19731973

1974+
//test zUnion with weights and aggegration function
1975+
$this->redis->zadd('key1', 1, 'duplicate');
1976+
$this->redis->zadd('key2', 2, 'duplicate');
1977+
$this->redis->zUnion('keyU', array('key1','key2'), array(1,1), 'MIN');
1978+
$this->assertTrue($this->redis->zScore('keyU', 'duplicate')===1.0);
1979+
$this->redis->delete('keyU');
1980+
1981+
//now test zUnion *without* weights but with aggregrate function
1982+
$this->redis->zUnion('keyU', array('key1','key2'), null, 'MIN');
1983+
$this->assertTrue($this->redis->zScore('keyU', 'duplicate')===1.0);
1984+
$this->redis->delete('keyU', 'key1', 'key2');
1985+
1986+
1987+
19741988
// test integer and float weights (GitHub issue #109).
19751989
$this->redis->del('key1', 'key2', 'key3');
19761990

@@ -2087,6 +2101,10 @@ public function testZX() {
20872101
$this->assertTrue( 2 === $this->redis->zInter('keyI', array('key1', 'key2', 'key3'), array(1, 5, 1), 'max'));
20882102
$this->assertTrue(array('val3', 'val1') === $this->redis->zRange('keyI', 0, -1));
20892103

2104+
$this->redis->delete('keyI');
2105+
$this->assertTrue(2 === $this->redis->zInter('keyI', array('key1', 'key2', 'key3'), null, 'max'));
2106+
$this->assertTrue($this->redis->zScore('keyI', 'val1') === floatval(7));
2107+
20902108
// zrank, zrevrank
20912109
$this->redis->delete('z');
20922110
$this->redis->zadd('z', 1, 'one');

0 commit comments

Comments
 (0)