summaryrefslogtreecommitdiffstats
path: root/7b8b7b01a2b2af2e646ca89802910ac216c476dc.patch
blob: 995b579aaa09884779b7e314210ace5a550c8f73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From 7b8b7b01a2b2af2e646ca89802910ac216c476dc Mon Sep 17 00:00:00 2001
From: michael-grunder <michael.grunder@gmail.com>
Date: Sat, 8 Dec 2018 15:10:34 -0800
Subject: [PATCH] Fix unit tests for Redis 5.0.2

Addresses issue #1472
---
 tests/RedisTest.php | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index 5f23a76a..8c358b6e 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -5392,7 +5392,7 @@ public function testXAck() {
 
         for ($n = 1; $n <= 3; $n++) {
             $this->addStreamsAndGroups(Array('{s}'), 3, Array('g1' => 0));
-            $msg = $this->redis->xReadGroup('g1', 'c1', Array('{s}' => 0));
+            $msg = $this->redis->xReadGroup('g1', 'c1', Array('{s}' => '>'));
 
             /* Extract IDs */
             $smsg = array_shift($msg);
@@ -5494,17 +5494,25 @@ public function testXReadGroup() {
 
         /* Create some streams and groups */
         $streams = Array('{s}-1', '{s}-2');
-        $qstreams = Array('{s}-1' => 0, '{s}-2' => 0);
         $groups = Array('g1' => 0, 'g2' => 0);
 
-        $ids = $this->addStreamsAndGroups($streams, 3, $groups);
+        /* I'm not totally sure why Redis behaves this way, but we have to
+         * send '>' first and then send ID '0' for subsequent xReadGroup calls
+         * or Redis will not return any messages.  This behavior changed from
+         * redis 5.0.1 and 5.0.2 but doing it this way works for both versions. */
+        $qcount = 0;
+        $query1 = Array('{s}-1' => '>', '{s}-2' => '>');
+        $query2 = Array('{s}-1' => '0', '{s}-2' => '0');
+
+        $ids = $this->addStreamsAndGroups($streams, 1, $groups);
 
         /* Test that we get get the IDs we should */
         foreach (Array('g1', 'g2') as $group) {
             foreach ($ids as $stream => $messages) {
                 while ($ids[$stream]) {
                     /* Read more messages */
-                    $resp = $this->redis->xReadGroup($group, 'consumer', $qstreams);
+                    $query = !$qcount++ ? $query1 : $query2;
+                    $resp = $this->redis->xReadGroup($group, 'consumer', $query);
 
                     /* They should match with our local control array */
                     $this->compareStreamIds($resp, $ids);
@@ -5519,7 +5527,7 @@ public function testXReadGroup() {
         /* Test COUNT option */
         for ($c = 1; $c <= 3; $c++) {
             $this->addStreamsAndGroups($streams, 3, $groups);
-            $resp = $this->redis->xReadGroup('g1', 'consumer', $qstreams, $c);
+            $resp = $this->redis->xReadGroup('g1', 'consumer', $query1, $c);
 
             foreach ($resp as $stream => $smsg) {
                 $this->assertEquals(count($smsg), $c);
@@ -5624,7 +5632,7 @@ public function testXClaim() {
                         $fids = $fids['f'];
 
                         /* Have consumer 'Mike' read the messages */
-                        $oids = $this->redis->xReadGroup('group1', 'Mike', Array('s' => 0));
+                        $oids = $this->redis->xReadGroup('group1', 'Mike', Array('s' => '>'));
                         $oids = array_keys($oids['s']); /* We're only dealing with stream 's' */
 
                         /* Construct our options array */