diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-10-10 23:20:14 +0300 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-10-11 08:55:35 +0300 |
commit | 3b0d8b77810a39a524b7c287d7ad646e93c20e60 (patch) | |
tree | 8679aa1d7e386300c94b820ca3080c6e96a23f7a /tests | |
parent | 525958ea9fd2f49b3f6683846f0641128d94a00e (diff) |
Refactor XINFO handler
Fixes #2119
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RedisTest.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php index 4023c37b..044c7884 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -6742,9 +6742,9 @@ class Redis_Test extends TestSuite public function testXInfo() { - if (!$this->minVersionCheck("5.0")) { - return $this->markTestSkipped(); - } + if (!$this->minVersionCheck("5.0")) + $this->markTestSkipped(); + /* Create some streams and groups */ $stream = 's'; $groups = ['g1' => 0, 'g2' => 0]; @@ -6767,6 +6767,12 @@ class Redis_Test extends TestSuite $this->assertTrue(is_array($info[$key])); } + /* Ensure that default/NULL arguments are ignored */ + $info = $this->redis->xInfo('STREAM', $stream, NULL); + $this->assertTrue(is_array($info)); + $info = $this->redis->xInfo('STREAM', $stream, NULL, -1); + $this->assertTrue(is_array($info)); + /* XINFO STREAM FULL [COUNT N] Requires >= 6.0.0 */ if (!$this->minVersionCheck("6.0")) return; @@ -6791,6 +6797,13 @@ class Redis_Test extends TestSuite $n = isset($info['entries']) ? count($info['entries']) : 0; $this->assertEquals($n, $this->redis->xLen($stream)); } + + /* Make sure we can't erroneously send non-null args after null ones */ + $this->redis->clearLastError(); + $this->assertFalse(@$this->redis->xInfo('FOO', NULL, 'fail', 25)); + $this->assertEquals(NULL, $this->redis->getLastError()); + $this->assertFalse(@$this->redis->xInfo('FOO', NULL, NULL, -2)); + $this->assertEquals(NULL, $this->redis->getLastError()); } /* Regression test for issue-1831 (XINFO STREAM on an empty stream) */ |