File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ public function pause()
4646
4747 public function resume ()
4848 {
49+ if (!$ this ->writable ->isWritable ()) {
50+ return ;
51+ }
52+
4953 if ($ this ->pipeSource ) {
5054 $ this ->pipeSource ->resume ();
5155 }
@@ -70,6 +74,7 @@ public function write($data)
7074
7175 public function end ($ data = null )
7276 {
77+ $ this ->readable ->pause ();
7378 $ this ->writable ->end ($ data );
7479 }
7580
Original file line number Diff line number Diff line change @@ -43,13 +43,35 @@ public function itShouldForwardReadableCallsToReadableStream()
4343 ->expects ($ this ->once ())
4444 ->method ('resume ' );
4545 $ writable = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
46+ $ writable
47+ ->expects ($ this ->any ())
48+ ->method ('isWritable ' )
49+ ->willReturn (true );
4650
4751 $ composite = new CompositeStream ($ readable , $ writable );
4852 $ composite ->isReadable ();
4953 $ composite ->pause ();
5054 $ composite ->resume ();
5155 }
5256
57+ /** @test */
58+ public function itShouldNotForwardResumeIfStreamIsNotWritable ()
59+ {
60+ $ readable = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
61+ $ readable
62+ ->expects ($ this ->never ())
63+ ->method ('resume ' );
64+
65+ $ writable = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
66+ $ writable
67+ ->expects ($ this ->once ())
68+ ->method ('isWritable ' )
69+ ->willReturn (false );
70+
71+ $ composite = new CompositeStream ($ readable , $ writable );
72+ $ composite ->resume ();
73+ }
74+
5375 /** @test */
5476 public function endShouldDelegateToWritableWithData ()
5577 {
You can’t perform that action at this time.
0 commit comments