File tree 5 files changed +18
-15
lines changed
5 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ public function createClient(string $uri): PromiseInterface
91
91
// either close successful connection or cancel pending connection attempt
92
92
$ connecting ->then (function (ConnectionInterface $ connection ) {
93
93
$ connection ->close ();
94
+ }, function () {
95
+ // ignore to avoid reporting unhandled rejection
94
96
});
95
97
assert (\method_exists ($ connecting , 'cancel ' ));
96
98
$ connecting ->cancel ();
Original file line number Diff line number Diff line change @@ -220,6 +220,8 @@ public function close(): void
220
220
if ($ this ->promise !== null ) {
221
221
$ this ->promise ->then (function (StreamingClient $ redis ) {
222
222
$ redis ->close ();
223
+ }, function () {
224
+ // ignore to avoid reporting unhandled rejection
223
225
});
224
226
if ($ this ->promise !== null ) {
225
227
assert (\method_exists ($ this ->promise , 'cancel ' ));
Original file line number Diff line number Diff line change @@ -161,15 +161,4 @@ public function testClose(): void
161
161
162
162
$ redis ->get ('willBeRejectedRightAway ' )->then (null , $ this ->expectCallableOnce ());
163
163
}
164
-
165
- public function testCloseLazy (): void
166
- {
167
- $ redis = new RedisClient ($ this ->uri , null , $ this ->loop );
168
-
169
- $ redis ->get ('willBeCanceledAnyway ' )->then (null , $ this ->expectCallableOnce ());
170
-
171
- $ redis ->close ();
172
-
173
- $ redis ->get ('willBeRejectedRightAway ' )->then (null , $ this ->expectCallableOnce ());
174
- }
175
164
}
Original file line number Diff line number Diff line change @@ -57,13 +57,17 @@ public function testCtor(): void
57
57
public function testWillConnectWithDefaultPort (): void
58
58
{
59
59
$ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('redis.example.com:6379 ' )->willReturn (reject (new \RuntimeException ()));
60
- $ this ->factory ->createClient ('redis.example.com ' );
60
+ $ promise = $ this ->factory ->createClient ('redis.example.com ' );
61
+
62
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
61
63
}
62
64
63
65
public function testWillConnectToLocalhost (): void
64
66
{
65
67
$ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('localhost:1337 ' )->willReturn (reject (new \RuntimeException ()));
66
- $ this ->factory ->createClient ('localhost:1337 ' );
68
+ $ promise = $ this ->factory ->createClient ('localhost:1337 ' );
69
+
70
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
67
71
}
68
72
69
73
public function testWillResolveIfConnectorResolves (): void
Original file line number Diff line number Diff line change @@ -161,7 +161,10 @@ public function testPingAfterPreviousFactoryRejectsUnderlyingClientWillCreateNew
161
161
new Promise (function () { })
162
162
);
163
163
164
- $ this ->redis ->ping ();
164
+ $ promise = $ this ->redis ->ping ();
165
+
166
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
167
+
165
168
$ deferred ->reject ($ error );
166
169
167
170
$ this ->redis ->ping ();
@@ -308,7 +311,10 @@ public function testCloseAfterPingWillEmitCloseWithoutErrorWhenUnderlyingClientC
308
311
$ this ->redis ->on ('error ' , $ this ->expectCallableNever ());
309
312
$ this ->redis ->on ('close ' , $ this ->expectCallableOnce ());
310
313
311
- $ this ->redis ->ping ();
314
+ $ promise = $ this ->redis ->ping ();
315
+
316
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
317
+
312
318
$ this ->redis ->close ();
313
319
}
314
320
You can’t perform that action at this time.
0 commit comments