@@ -35,6 +35,8 @@ public function testPing(): void
35
35
36
36
public function testPingLazy (): void
37
37
{
38
+ $ this ->markTestSkipped ('segfaults with ext-debug? ' );
39
+
38
40
$ redis = new RedisClient ($ this ->uri );
39
41
40
42
/** @var PromiseInterface<string> */
@@ -176,4 +178,46 @@ public function testClose(): void
176
178
177
179
$ redis ->get ('willBeRejectedRightAway ' )->then (null , $ this ->expectCallableOnce ());
178
180
}
181
+
182
+ public function testCloneWhenOriginalIsIdleReturnsClientThatWillCloseIndependently (): void
183
+ {
184
+ $ prefix = 'test: ' . mt_rand () . ': ' ;
185
+ $ original = new RedisClient ($ this ->uri );
186
+
187
+ $ this ->assertNull (await ($ original ->callAsync ('GET ' , $ prefix . 'doesnotexist ' )));
188
+
189
+ $ redis = clone $ original ;
190
+
191
+ $ this ->assertNull (await ($ redis ->callAsync ('GET ' , $ prefix . 'doesnotexist ' )));
192
+ }
193
+
194
+ public function testCloneWhenOriginalIsPendingReturnsClientThatWillCloseIndependently (): void
195
+ {
196
+ $ prefix = 'test: ' . mt_rand () . ': ' ;
197
+ $ original = new RedisClient ($ this ->uri );
198
+
199
+ $ this ->assertNull (await ($ original ->callAsync ('GET ' , $ prefix . 'doesnotexist ' )));
200
+ $ promise = $ original ->callAsync ('GET ' , $ prefix . 'doesnotexist ' );
201
+
202
+ $ redis = clone $ original ;
203
+
204
+ $ this ->assertNull (await ($ redis ->callAsync ('GET ' , $ prefix . 'doesnotexist ' )));
205
+ $ this ->assertNull (await ($ promise ));
206
+ }
207
+
208
+ public function testCloneReturnsClientNotAffectedByPubSubSubscriptions (): void
209
+ {
210
+ $ prefix = 'test: ' . mt_rand () . ': ' ;
211
+ $ consumer = new RedisClient ($ this ->uri );
212
+
213
+ $ consumer ->on ('message ' , $ this ->expectCallableNever ());
214
+ $ consumer ->on ('pmessage ' , $ this ->expectCallableNever ());
215
+ await ($ consumer ->callAsync ('SUBSCRIBE ' , $ prefix . 'demo ' ));
216
+ await ($ consumer ->callAsync ('PSUBSCRIBE ' , $ prefix . '* ' ));
217
+
218
+ $ redis = clone $ consumer ;
219
+ $ consumer ->close ();
220
+
221
+ $ this ->assertNull (await ($ redis ->callAsync ('GET ' , $ prefix . 'doesnotexist ' )));
222
+ }
179
223
}
0 commit comments