@@ -272,4 +272,34 @@ public function testEmitsMessageEventWhenUnderlyingClientEmitsMessageForPubSubCh
272272 $ this ->client ->on ('message ' , $ this ->expectCallableOnce ());
273273 $ client ->emit ('message ' , array ('foo ' , 'bar ' ));
274274 }
275+
276+ public function testEmitsUnsubscribeAndPunsubscribeEventsWhenUnderlyingClientClosesWhileUsingPubSubChannel ()
277+ {
278+ $ client = $ this ->getMockBuilder ('Clue\React\Redis\StreamingClient ' )->disableOriginalConstructor ()->setMethods (array ('__call ' ))->getMock ();
279+ $ client ->expects ($ this ->exactly (6 ))->method ('__call ' )->willReturn (\React \Promise \resolve ());
280+
281+ $ this ->factory ->expects ($ this ->once ())->method ('createClient ' )->willReturn (\React \Promise \resolve ($ client ));
282+
283+ $ this ->client ->subscribe ('foo ' );
284+ $ client ->emit ('subscribe ' , array ('foo ' , 1 ));
285+
286+ $ this ->client ->subscribe ('bar ' );
287+ $ client ->emit ('subscribe ' , array ('bar ' , 2 ));
288+
289+ $ this ->client ->unsubscribe ('bar ' );
290+ $ client ->emit ('unsubscribe ' , array ('bar ' , 1 ));
291+
292+ $ this ->client ->psubscribe ('foo* ' );
293+ $ client ->emit ('psubscribe ' , array ('foo* ' , 1 ));
294+
295+ $ this ->client ->psubscribe ('bar* ' );
296+ $ client ->emit ('psubscribe ' , array ('bar* ' , 2 ));
297+
298+ $ this ->client ->punsubscribe ('bar* ' );
299+ $ client ->emit ('punsubscribe ' , array ('bar* ' , 1 ));
300+
301+ $ this ->client ->on ('unsubscribe ' , $ this ->expectCallableOnce ());
302+ $ this ->client ->on ('punsubscribe ' , $ this ->expectCallableOnce ());
303+ $ client ->emit ('close ' );
304+ }
275305}
0 commit comments