@@ -238,6 +238,16 @@ public function testClosingInputWillCloseParser()
238238 $ this ->assertFalse ($ this ->parser ->isReadable ());
239239 }
240240
241+ public function testClosingInputWillRemoveAllDataListeners ()
242+ {
243+ $ this ->parser ->on ('data ' , $ this ->expectCallableNever ());
244+
245+ $ this ->input ->close ();
246+
247+ $ this ->assertEquals (array (), $ this ->input ->listeners ('data ' ));
248+ $ this ->assertEquals (array (), $ this ->parser ->listeners ('data ' ));
249+ }
250+
241251 public function testClosingParserWillCloseInput ()
242252 {
243253 $ this ->input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
@@ -252,6 +262,19 @@ public function testClosingParserWillCloseInput()
252262 $ this ->assertFalse ($ this ->parser ->isReadable ());
253263 }
254264
265+ public function testClosingParserWillRemoveAllDataListeners ()
266+ {
267+ $ this ->input = new ReadableStream ();
268+ $ this ->parser = new ControlCodeParser ($ this ->input );
269+
270+ $ this ->parser ->on ('data ' , $ this ->expectCallableNever ());
271+
272+ $ this ->parser ->close ();
273+
274+ $ this ->assertEquals (array (), $ this ->input ->listeners ('data ' ));
275+ $ this ->assertEquals (array (), $ this ->parser ->listeners ('data ' ));
276+ }
277+
255278 public function testClosingParserMultipleTimesWillOnlyCloseOnce ()
256279 {
257280 $ this ->input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
@@ -275,6 +298,17 @@ public function testPassingClosedInputToParserWillCloseParser()
275298 $ this ->assertFalse ($ this ->parser ->isReadable ());
276299 }
277300
301+ public function testPassingClosedInputToParserWillNotAddAnyDataListeners ()
302+ {
303+ $ this ->input = new ReadableStream ();
304+ $ this ->input ->close ();
305+
306+ $ this ->parser = new ControlCodeParser ($ this ->input );
307+
308+ $ this ->assertEquals (array (), $ this ->input ->listeners ('data ' ));
309+ $ this ->assertEquals (array (), $ this ->parser ->listeners ('data ' ));
310+ }
311+
278312 public function testWillForwardPauseToInput ()
279313 {
280314 $ this ->input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
0 commit comments