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
path: root/tests
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2022-10-01 20:25:54 +0300
committerMichael Grunder <michael.grunder@gmail.com>2022-10-01 20:42:23 +0300
commit643005080839b35c40d78af40eda3e2743ad4d6f (patch)
tree51a2f7e4c3ad1fe09ef09119efb69d3075265eb8 /tests
parent239678a03bb9efcd30893a99c37ba62d22d22b5d (diff)
SINTERCARD and ZINTERCARD commands
Implement Redis 7.0.0 commands SINTERCARD and ZINTERCARD.
Diffstat (limited to 'tests')
-rw-r--r--tests/RedisTest.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index 6c04c9d0..551c6346 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -1948,6 +1948,55 @@ class Redis_Test extends TestSuite
$this->assertTrue($count === 0);
}
+ public function testInterCard() {
+ if(version_compare($this->version, "7.0.0") < 0) {
+ $this->markTestSkipped();
+ }
+
+ $set_data = [
+ ['aardvark', 'dog', 'fish', 'squirrel', 'tiger'],
+ ['bear', 'coyote', 'fish', 'gorilla', 'dog']
+ ];
+
+ $ssets = $zsets = [];
+
+ foreach ($set_data as $n => $values) {
+ $sset = "s{set}:$n";
+ $zset = "z{set}:$n";
+
+ $this->redis->del([$sset, $zset]);
+
+ $ssets[] = $sset;
+ $zsets[] = $zset;
+
+ foreach ($values as $score => $value) {
+ $this->assertEquals(1, $this->redis->sAdd("s{set}:$n", $value));
+ $this->assertEquals(1, $this->redis->zAdd("z{set}:$n", $score, $value));
+ }
+ }
+
+ $exp = count(array_intersect(...$set_data));
+
+ $act = $this->redis->sintercard($ssets);
+ $this->assertEquals($exp, $act);
+ $act = $this->redis->zintercard($zsets);
+ $this->assertEquals($exp, $act);
+
+ $this->assertEquals(1, $this->redis->sintercard($ssets, 1));
+ $this->assertEquals(2, $this->redis->sintercard($ssets, 2));
+
+ $this->assertEquals(1, $this->redis->zintercard($zsets, 1));
+ $this->assertEquals(2, $this->redis->zintercard($zsets, 2));
+
+ $this->assertFalse(@$this->redis->sintercard($ssets, -1));
+ $this->assertFalse(@$this->redis->zintercard($ssets, -1));
+
+ $this->assertFalse(@$this->redis->sintercard([]));
+ $this->assertFalse(@$this->redis->zintercard([]));
+
+ $this->redis->del(array_merge($ssets, $zsets));
+ }
+
public function testlrange() {
$this->redis->del('list');
$this->redis->lPush('list', 'val');