File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -217,8 +217,10 @@ public function close()
217
217
$ this ->connecting ->then (function (ConnectionInterface $ connection ) {
218
218
$ connection ->close ();
219
219
});
220
- $ this ->connecting ->cancel ();
221
- $ this ->connecting = null ;
220
+ if ($ this ->connecting !== null ) {
221
+ $ this ->connecting ->cancel ();
222
+ $ this ->connecting = null ;
223
+ }
222
224
}
223
225
224
226
if ($ this ->idleTimer !== null ) {
Original file line number Diff line number Diff line change @@ -678,6 +678,25 @@ public function testCloseAfterPingWillCancelTimerWhenPingFromUnderlyingConnectio
678
678
$ connection ->close ();
679
679
}
680
680
681
+ public function testCloseAfterPingHasResolvedWillCloseUnderlyingConnectionWithoutTryingToCancelConnection ()
682
+ {
683
+ $ base = $ this ->getMockBuilder ('React\MySQL\Io\LazyConnection ' )->setMethods (array ('ping ' , 'close ' ))->disableOriginalConstructor ()->getMock ();
684
+ $ base ->expects ($ this ->once ())->method ('ping ' )->willReturn (\React \Promise \resolve ());
685
+ $ base ->expects ($ this ->once ())->method ('close ' )->willReturnCallback (function () use ($ base ) {
686
+ $ base ->emit ('close ' );
687
+ });
688
+
689
+ $ factory = $ this ->getMockBuilder ('React\MySQL\Factory ' )->disableOriginalConstructor ()->getMock ();
690
+ $ factory ->expects ($ this ->once ())->method ('createConnection ' )->willReturn (\React \Promise \resolve ($ base ));
691
+
692
+ $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
693
+
694
+ $ connection = new LazyConnection ($ factory , '' , $ loop );
695
+
696
+ $ connection ->ping ();
697
+ $ connection ->close ();
698
+ }
699
+
681
700
public function testCloseAfterQuitAfterPingWillCloseUnderlyingConnectionWhenQuitIsStillPending ()
682
701
{
683
702
$ base = $ this ->getMockBuilder ('React\MySQL\ConnectionInterface ' )->getMock ();
You can’t perform that action at this time.
0 commit comments