@@ -72,11 +72,12 @@ public function testSession_lockWaitTime() { $this->markTestSkipped(); }
7272
7373 /* Regression test for GH #2810 */
7474 public function testConstructNullSeeds () {
75+ $ class = $ this ->getRedisClusterClass ();
7576 /* new RedisCluster(null, null) must not throw TypeError.
7677 * $seeds is declared ?array so null is a valid argument. */
7778 $ thrown = false ;
7879 try {
79- new RedisCluster (null , null );
80+ new $ class (null , null );
8081 } catch (\Throwable $ e ) {
8182 $ thrown = true ;
8283 $ this ->assertFalse ($ e instanceof \TypeError);
@@ -86,7 +87,7 @@ public function testConstructNullSeeds() {
8687 /* Passing an empty array must also not throw TypeError (control). */
8788 $ thrown = false ;
8889 try {
89- new RedisCluster (null , []);
90+ new $ class (null , []);
9091 } catch (\Throwable $ e ) {
9192 $ thrown = true ;
9293 $ this ->assertFalse ($ e instanceof \TypeError);
@@ -96,17 +97,18 @@ public function testConstructNullSeeds() {
9697 /* Both (null) and (null, null) mean "no name, no seeds" and must
9798 * produce the same exception type. */
9899 $ ex1 = $ ex2 = null ;
99- try { new RedisCluster (null ); }
100+ try { new $ class (null ); }
100101 catch (\Throwable $ e ) { $ ex1 = get_class ($ e ); }
101- try { new RedisCluster (null , null ); }
102+ try { new $ class (null , null ); }
102103 catch (\Throwable $ e ) { $ ex2 = get_class ($ e ); }
103104 $ this ->assertTrue ($ ex1 !== null );
104105 $ this ->assertEquals ($ ex1 , $ ex2 );
105106 }
106107
107108 private function loadSeedsFromHostPort ($ host , $ port ) {
109+ $ class = $ this ->getRedisClusterClass ();
108110 try {
109- $ rc = new RedisCluster (NULL , ["$ host: $ port " ], 1 , 1 , true , $ this ->getAuth ());
111+ $ rc = new $ class (NULL , ["$ host: $ port " ], 1 , 1 , true , $ this ->getAuth ());
110112 self ::$ seed_source = "Host: $ host, Port: $ port " ;
111113 return array_map (function ($ master ) {
112114 return sprintf ('%s:%s ' , $ master [0 ], $ master [1 ]);
@@ -203,16 +205,17 @@ private function getServerReply($host, $port, $cmd) {
203205 runners. If we're not on a runner we just get a new instance. Otherwise
204206 we allow for two tries to get the instance. */
205207 private function getNewInstance () {
208+ $ class = $ this ->getRedisClusterClass ();
206209 if (getenv ('GITHUB_ACTIONS ' ) === 'true ' ) {
207210 try {
208- return new RedisCluster (NULL , self ::$ seeds , 30 , 30 , true ,
209- $ this ->getAuth ());
211+ return new $ class (NULL , self ::$ seeds , 30 , 30 , true ,
212+ $ this ->getAuth ());
210213 } catch (Exception $ ex ) {
211214 TestSuite::errorMessage ("Failed to connect: %s " , $ ex ->getMessage ());
212215 }
213216 }
214217
215- return new RedisCluster (NULL , self ::$ seeds , 30 , 30 , true , $ this ->getAuth ());
218+ return new $ class (NULL , self ::$ seeds , 30 , 30 , true , $ this ->getAuth ());
216219 }
217220
218221 /* Override newInstance as we want a RedisCluster object */
@@ -271,6 +274,7 @@ public function testPing() {
271274 }
272275
273276 public function testDirectedCommandsRejectUncoveredSlot () {
277+ $ class = $ this ->getRedisClusterClass ();
274278 for ($ i = 0 ; $ i < 256 ; $ i ++) {
275279 $ key = "{uncovered-directed- $ i}key " ;
276280 $ slot = $ this ->redis ->cluster ($ key , 'KEYSLOT ' , $ key );
@@ -296,7 +300,7 @@ public function testDirectedCommandsRejectUncoveredSlot() {
296300 }
297301 $ removed = true ;
298302 /* Map from the owner so the object's slot table contains the hole. */
299- $ client = new RedisCluster (null , ["{$ master [0 ]}: {$ master [1 ]}" ],
303+ $ client = new $ class (null , ["{$ master [0 ]}: {$ master [1 ]}" ],
300304 1 , 1 , false , $ this ->getAuth ());
301305
302306 /* GET already has this guard; directed commands must reject the slot too. */
@@ -448,7 +452,8 @@ private function replicasForKey(string $key): array {
448452 /* Directed RedisCluster commands can only address a node that owns slots,
449453 * so talk to a replica over a plain Redis connection instead. */
450454 private function connectToNode (array $ node ) {
451- $ redis = new Redis (['host ' => $ node [0 ], 'port ' => $ node [1 ]]);
455+ $ class = $ this ->getRedisClass ();
456+ $ redis = new $ class (['host ' => $ node [0 ], 'port ' => $ node [1 ]]);
452457
453458 if ($ this ->getAuth ())
454459 $ this ->assertTrue ($ redis ->auth ($ this ->getAuth ()));
@@ -474,6 +479,7 @@ private function movedCount(array $nodes): int {
474479 * READONLY we sent doesn't survive the new connection, so we have to send
475480 * it again or the replica answers MOVED to every read we send it. */
476481 public function testReplicaReadonlyResentAfterReconnect () {
482+ $ class = $ this ->getRedisClusterClass ();
477483 if ( ! $ this ->minVersionCheck ('6.2.0 ' ))
478484 $ this ->markTestSkipped ('INFO ERRORSTATS requires Redis >= 6.2.0 ' );
479485
@@ -487,7 +493,7 @@ public function testReplicaReadonlyResentAfterReconnect() {
487493 /* Without READONLY every read bounces on MOVED until the redirection
488494 * loop gives up after timeout + read_timeout, so keep those short or a
489495 * regression takes the default 60 seconds per read to surface. */
490- $ client = new RedisCluster (NULL , self ::$ seeds , 1 , 1 , false , $ this ->getAuth ());
496+ $ client = new $ class (NULL , self ::$ seeds , 1 , 1 , false , $ this ->getAuth ());
491497 $ client ->setOption (RedisCluster::OPT_SLAVE_FAILOVER ,
492498 RedisCluster::FAILOVER_DISTRIBUTE_SLAVES );
493499
@@ -1013,7 +1019,7 @@ protected function checkKeyValue($key, $key_type, $value) {
10131019 $ this ->assertEquals ($ value , $ this ->redis ->lrange ($ key , 0 , -1 ));
10141020 break ;
10151021 case Redis::REDIS_HASH :
1016- $ this ->assertEquals ($ value , $ this ->redis ->hgetall ($ key ));
1022+ $ this ->assertEqualsCanonicalizing ($ value , $ this ->redis ->hgetall ($ key ), true );
10171023 break ;
10181024 case Redis::REDIS_ZSET :
10191025 $ this ->checkZSetEquality ($ value , $ this ->redis ->zrange ($ key , 0 , -1 , true ));
0 commit comments