@@ -200,6 +200,30 @@ public function testForwardsPauseToInputStream()
200200 $ stream ->pause ();
201201 }
202202
203+ /**
204+ * @doesNotPerformAssertions
205+ */
206+ public function testPauseAfterCloseHasNoEffect ()
207+ {
208+ $ promise = new \React \Promise \Promise (function () { });
209+ $ stream = Stream \unwrapReadable ($ promise );
210+
211+ $ stream ->close ();
212+ $ stream ->pause ();
213+ }
214+
215+
216+ /**
217+ * @doesNotPerformAssertions
218+ */
219+ public function testPauseAfterErrorDueToInvalidInputHasNoEffect ()
220+ {
221+ $ promise = \React \Promise \reject (new \RuntimeException ());
222+ $ stream = Stream \unwrapReadable ($ promise );
223+
224+ $ stream ->pause ();
225+ }
226+
203227 public function testForwardsResumeToInputStream ()
204228 {
205229 $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
@@ -211,6 +235,18 @@ public function testForwardsResumeToInputStream()
211235 $ stream ->resume ();
212236 }
213237
238+ /**
239+ * @doesNotPerformAssertions
240+ */
241+ public function testResumeAfterCloseHasNoEffect ()
242+ {
243+ $ promise = new \React \Promise \Promise (function () { });
244+ $ stream = Stream \unwrapReadable ($ promise );
245+
246+ $ stream ->close ();
247+ $ stream ->resume ();
248+ }
249+
214250 public function testPipingStreamWillForwardDataEvents ()
215251 {
216252 $ input = new ThroughStream ();
@@ -279,4 +315,31 @@ public function testClosingStreamWillCloseStreamFromCancellationHandler()
279315
280316 $ this ->assertFalse ($ input ->isReadable ());
281317 }
318+
319+ public function testCloseShouldRemoveAllListenersAfterCloseEvent ()
320+ {
321+ $ promise = new \React \Promise \Promise (function () { });
322+ $ stream = Stream \unwrapReadable ($ promise );
323+
324+ $ stream ->on ('close ' , $ this ->expectCallableOnce ());
325+ $ this ->assertCount (1 , $ stream ->listeners ('close ' ));
326+
327+ $ stream ->close ();
328+
329+ $ this ->assertCount (0 , $ stream ->listeners ('close ' ));
330+ }
331+
332+ public function testCloseShouldRemoveReferenceToPromiseToAvoidGarbageReferences ()
333+ {
334+ $ promise = new \React \Promise \Promise (function () { });
335+ $ stream = Stream \unwrapReadable ($ promise );
336+
337+ $ stream ->close ();
338+
339+ $ ref = new \ReflectionProperty ($ stream , 'promise ' );
340+ $ ref ->setAccessible (true );
341+ $ value = $ ref ->getValue ($ stream );
342+
343+ $ this ->assertNull ($ value );
344+ }
282345}
0 commit comments