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-22 22:46:26 +0300
committerMichael Grunder <michael.grunder@gmail.com>2022-10-23 21:37:20 +0300
commit1343f5008301a256fcbfa0161931e2a39791055f (patch)
tree998e0199f979755ea09e2ab3209353211a4dee3e /tests
parent71bcbcb973413ae933cf30d58254dfb02425c1ed (diff)
XGROUP DELCONSUMER and ENTRIESREAD
Refactor XGROUP and implement the new DELCONSUMER (Redis 6.2.0) and ENTRIESREAD (Redis 7.0.0) options. Additionally, add a proper phpdoc block to the stub file. See #2068
Diffstat (limited to 'tests')
-rw-r--r--tests/RedisTest.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index 149bbb84..ea036ebc 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -6521,6 +6521,40 @@ class Redis_Test extends TestSuite
$this->assertFalse($this->redis->xGroup('SETID', 's', 'mygroup', 'BAD_ID'));
$this->assertEquals($this->redis->xGroup('DELCONSUMER', 's', 'mygroup', 'myconsumer'),0);
+
+ if (!$this->minVersionCheck('6.2.0'))
+ return;
+
+ /* CREATECONSUMER */
+ $this->assertTrue($this->redis->del('s'));
+ $this->assertTrue($this->redis->xgroup('create', 's', 'mygroup', '$', true));
+ for ($i = 0; $i < 3; $i++) {
+ $this->assertTrue($this->redis->xgroup('createconsumer', 's', 'mygroup', "c:$i"));
+ $info = $this->redis->xinfo('consumers', 's', 'mygroup');
+ $this->assertTrue(is_array($info) && count($info) == $i + 1);
+ for ($j = 0; $j <= $i; $j++) {
+ $this->assertTrue(isset($info[$j]) && isset($info[$j]['name']) && $info[$j]['name'] == "c:$j");
+ }
+ }
+
+ /* Make sure we don't erroneously send options that don't belong to the operation */
+ $this->assertTrue($this->redis->xGroup('CREATECONSUMER', 's', 'mygroup', 'fake-consumer', true, 1337));
+
+ /* Make sure we handle the case where the user doesn't send enough arguments */
+ $this->redis->clearLastError();
+ $this->assertFalse(@$this->redis->xGroup('CREATECONSUMER'));
+ $this->assertEquals(NULL, $this->redis->getLastError());
+ $this->assertFalse(@$this->redis->xGroup('create'));
+ $this->assertEquals(NULL, $this->redis->getLastError());
+
+ if (!$this->minVersionCheck('7.0.0'))
+ return;
+
+ /* ENTRIESREAD */
+ $this->assertTrue($this->redis->del('s'));
+ $this->assertTrue($this->redis->xGroup('create', 's', 'mygroup', '$', true, 1337));
+ $info = $this->redis->xinfo('groups', 's');
+ $this->assertTrue(isset($info[0]['entries-read']) && 1337 == (int)$info[0]['entries-read']);
}
public function testXAck() {