@@ -58,8 +58,8 @@ public function testChunkedEncoding(array $strings, $expected = "Wikipedia in\r\
5858 $ response ->on ('data ' , function ($ data ) use (&$ buffer ) {
5959 $ buffer .= $ data ;
6060 });
61- $ response ->on ('error ' , function (Exception $ exception ) {
62- throw $ exception ;
61+ $ response ->on ('error ' , function ($ error ) {
62+ $ this -> fail (( string ) $ error ) ;
6363 });
6464 foreach ($ strings as $ string ) {
6565 $ stream ->write ($ string );
@@ -104,6 +104,9 @@ public function testHandleEnd()
104104 $ ended = false ;
105105 $ stream = new ThroughStream ();
106106 $ response = new ChunkedStreamDecoder ($ stream );
107+ $ response ->on ('error ' , function ($ error ) {
108+ $ this ->fail ((string )$ error );
109+ });
107110 $ response ->on ('end ' , function () use (&$ ended ) {
108111 $ ended = true ;
109112 });
@@ -132,6 +135,9 @@ public function testHandleEndTrailers()
132135 $ ended = false ;
133136 $ stream = new ThroughStream ();
134137 $ response = new ChunkedStreamDecoder ($ stream );
138+ $ response ->on ('error ' , function ($ error ) {
139+ $ this ->fail ((string )$ error );
140+ });
135141 $ response ->on ('end ' , function () use (&$ ended ) {
136142 $ ended = true ;
137143 });
@@ -140,4 +146,23 @@ public function testHandleEndTrailers()
140146
141147 $ this ->assertTrue ($ ended );
142148 }
149+
150+ public function testHandleEndEnsureNoError ()
151+ {
152+ $ ended = false ;
153+ $ stream = new ThroughStream ();
154+ $ response = new ChunkedStreamDecoder ($ stream );
155+ $ response ->on ('error ' , function ($ error ) {
156+ $ this ->fail ((string )$ error );
157+ });
158+ $ response ->on ('end ' , function () use (&$ ended ) {
159+ $ ended = true ;
160+ });
161+
162+ $ stream ->write ("4 \r\nWiki \r\n" );
163+ $ stream ->write ("0 \r\n\r\n" );
164+ $ stream ->end ();
165+
166+ $ this ->assertTrue ($ ended );
167+ }
143168}
0 commit comments