File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ public function idle()
201201 {
202202 --$ this ->pending ;
203203
204- if ($ this ->pending < 1 && $ this ->idlePeriod >= 0 && !$ this ->subscribed && !$ this ->psubscribed ) {
204+ if ($ this ->pending < 1 && $ this ->idlePeriod >= 0 && !$ this ->subscribed && !$ this ->psubscribed && $ this -> promise !== null ) {
205205 $ idleTimer =& $ this ->idleTimer ;
206206 $ promise =& $ this ->promise ;
207207 $ idleTimer = $ this ->loop ->addTimer ($ this ->idlePeriod , function () use (&$ idleTimer , &$ promise ) {
Original file line number Diff line number Diff line change @@ -573,6 +573,33 @@ public function testUnsubscribeAfterSubscribeWillResolveWhenUnderlyingClientReso
573573 $ promise ->then ($ this ->expectCallableOnceWith (array ('unsubscribe ' , 'foo ' , 0 )));
574574 }
575575
576+ public function testBlpopWillRejectWhenUnderlyingClientClosesWhileWaitingForResponse ()
577+ {
578+ $ closeHandler = null ;
579+ $ deferred = new Deferred ();
580+ $ client = $ this ->getMockBuilder ('Clue\React\Redis\Client ' )->getMock ();
581+ $ client ->expects ($ this ->once ())->method ('__call ' )->with ('blpop ' )->willReturn ($ deferred ->promise ());
582+ $ client ->expects ($ this ->any ())->method ('on ' )->withConsecutive (
583+ array ('close ' , $ this ->callback (function ($ arg ) use (&$ closeHandler ) {
584+ $ closeHandler = $ arg ;
585+ return true ;
586+ }))
587+ );
588+
589+ $ this ->factory ->expects ($ this ->once ())->method ('createClient ' )->willReturn (\React \Promise \resolve ($ client ));
590+
591+ $ this ->loop ->expects ($ this ->never ())->method ('addTimer ' );
592+
593+ $ promise = $ this ->client ->blpop ('list ' );
594+
595+ $ this ->assertTrue (is_callable ($ closeHandler ));
596+ $ closeHandler ();
597+
598+ $ deferred ->reject ($ e = new \RuntimeException ());
599+
600+ $ promise ->then (null , $ this ->expectCallableOnceWith ($ e ));
601+ }
602+
576603 public function createCallableMockWithOriginalConstructorDisabled ($ array )
577604 {
578605 if (method_exists ('PHPUnit\Framework\MockObject\MockBuilder ' , 'addMethods ' )) {
You can’t perform that action at this time.
0 commit comments