File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 66
77final class CompositeStream extends EventEmitter implements DuplexStreamInterface
88{
9- protected $ readable ;
10- protected $ writable ;
11- protected $ closed = false ;
9+ private $ readable ;
10+ private $ writable ;
11+ private $ closed = false ;
1212
1313 public function __construct (ReadableStreamInterface $ readable , WritableStreamInterface $ writable )
1414 {
@@ -77,5 +77,6 @@ public function close()
7777 $ this ->writable ->close ();
7878
7979 $ this ->emit ('close ' );
80+ $ this ->removeAllListeners ();
8081 }
8182}
Original file line number Diff line number Diff line change @@ -188,6 +188,25 @@ public function itShouldForwardCloseOnlyOnce()
188188 $ writable ->close ();
189189 }
190190
191+ /** @test */
192+ public function itShouldForwardCloseAndRemoveAllListeners ()
193+ {
194+ $ in = new ThroughStream ();
195+
196+ $ composite = new CompositeStream ($ in , $ in );
197+ $ composite ->on ('close ' , $ this ->expectCallableOnce ());
198+
199+ $ this ->assertTrue ($ composite ->isReadable ());
200+ $ this ->assertTrue ($ composite ->isWritable ());
201+ $ this ->assertCount (1 , $ composite ->listeners ('close ' ));
202+
203+ $ composite ->close ();
204+
205+ $ this ->assertFalse ($ composite ->isReadable ());
206+ $ this ->assertFalse ($ composite ->isWritable ());
207+ $ this ->assertCount (0 , $ composite ->listeners ('close ' ));
208+ }
209+
191210 /** @test */
192211 public function itShouldReceiveForwardedEvents ()
193212 {
You can’t perform that action at this time.
0 commit comments