File tree Expand file tree Collapse file tree 5 files changed +18
-15
lines changed Expand file tree Collapse file tree 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
9191 // either close successful connection or cancel pending connection attempt
9292 $ connecting ->then (function (ConnectionInterface $ connection ) {
9393 $ connection ->close ();
94+ }, function () {
95+ // ignore to avoid reporting unhandled rejection
9496 });
9597 assert (\method_exists ($ connecting , 'cancel ' ));
9698 $ connecting ->cancel ();
Original file line number Diff line number Diff line change @@ -220,6 +220,8 @@ public function close(): void
220220 if ($ this ->promise !== null ) {
221221 $ this ->promise ->then (function (StreamingClient $ redis ) {
222222 $ redis ->close ();
223+ }, function () {
224+ // ignore to avoid reporting unhandled rejection
223225 });
224226 if ($ this ->promise !== null ) {
225227 assert (\method_exists ($ this ->promise , 'cancel ' ));
Original file line number Diff line number Diff line change @@ -161,15 +161,4 @@ public function testClose(): void
161161
162162 $ redis ->get ('willBeRejectedRightAway ' )->then (null , $ this ->expectCallableOnce ());
163163 }
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- }
175164}
Original file line number Diff line number Diff line change @@ -57,13 +57,17 @@ public function testCtor(): void
5757 public function testWillConnectWithDefaultPort (): void
5858 {
5959 $ 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
6163 }
6264
6365 public function testWillConnectToLocalhost (): void
6466 {
6567 $ 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
6771 }
6872
6973 public function testWillResolveIfConnectorResolves (): void
Original file line number Diff line number Diff line change @@ -161,7 +161,10 @@ public function testPingAfterPreviousFactoryRejectsUnderlyingClientWillCreateNew
161161 new Promise (function () { })
162162 );
163163
164- $ this ->redis ->ping ();
164+ $ promise = $ this ->redis ->ping ();
165+
166+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
167+
165168 $ deferred ->reject ($ error );
166169
167170 $ this ->redis ->ping ();
@@ -308,7 +311,10 @@ public function testCloseAfterPingWillEmitCloseWithoutErrorWhenUnderlyingClientC
308311 $ this ->redis ->on ('error ' , $ this ->expectCallableNever ());
309312 $ this ->redis ->on ('close ' , $ this ->expectCallableOnce ());
310313
311- $ this ->redis ->ping ();
314+ $ promise = $ this ->redis ->ping ();
315+
316+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
317+
312318 $ this ->redis ->close ();
313319 }
314320
You can’t perform that action at this time.
0 commit comments