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()
201
201
{
202
202
--$ this ->pending ;
203
203
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 ) {
205
205
$ idleTimer =& $ this ->idleTimer ;
206
206
$ promise =& $ this ->promise ;
207
207
$ 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
573
573
$ promise ->then ($ this ->expectCallableOnceWith (array ('unsubscribe ' , 'foo ' , 0 )));
574
574
}
575
575
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
+
576
603
public function createCallableMockWithOriginalConstructorDisabled ($ array )
577
604
{
578
605
if (method_exists ('PHPUnit\Framework\MockObject\MockBuilder ' , 'addMethods ' )) {
You can’t perform that action at this time.
0 commit comments