@@ -141,8 +141,7 @@ public function testCanDetachStream(){
141141 }
142142
143143 public function testCloseClearProperties (){
144- $ handle = fopen ('php://temp ' , 'r+ ' );
145- $ stream = new Stream ($ handle );
144+ $ stream = create_stream ();
146145 $ stream ->close ();
147146
148147 $ this ->assertFalse ($ stream ->isSeekable ());
@@ -153,8 +152,7 @@ public function testCloseClearProperties(){
153152 }
154153
155154 public function testStreamReadingWithZeroLength (){
156- $ r = fopen ('php://temp ' , 'r ' );
157- $ stream = new Stream ($ r );
155+ $ stream = create_stream ();
158156
159157 $ this ->assertSame ('' , $ stream ->read (0 ));
160158
@@ -165,19 +163,16 @@ public function testStreamReadingWithNegativeLength(){
165163 $ this ->expectException (RuntimeException::class);
166164 $ this ->expectExceptionMessage ('Length parameter cannot be negative ' );
167165
168- $ r = fopen ('php://temp ' , 'r ' );
169- $ stream = new Stream ($ r );
166+ $ stream = create_stream ();
167+ $ stream ->read (-1 );
168+ }
170169
171- try {
172- $ stream ->read (-1 );
173- }
174- catch (\Exception $ e ){
175- $ stream ->close ();
176- /** @noinspection PhpUnhandledExceptionInspection */
177- throw $ e ;
178- }
170+ public function testStreamSeekInvalidPosition (){
171+ $ this ->expectException (RuntimeException::class);
172+ $ this ->expectExceptionMessage ('Unable to seek to stream position -1 with whence 0 ' );
179173
180- $ stream ->close ();
174+ $ stream = create_stream ();
175+ $ stream ->seek (-1 );
181176 }
182177
183178}
0 commit comments