@@ -27,14 +27,32 @@ public function testFlockWithFilePutContents(): void
2727 $ this ->assertEquals (\strlen ($ testData ), $ res );
2828 }
2929
30+ public function testSetStreamOptions (): void
31+ {
32+ $ processor = new StreamProcessor ();
33+ $ processor ->intercept ();
34+
35+ $ handle = fopen ('tests/fixtures/file_put_contents ' , 'w ' );
36+
37+ self ::assertTrue (stream_set_blocking ($ handle , true ));
38+ self ::assertFalse (stream_set_timeout ($ handle , 10 ));
39+ self ::assertFalse (stream_set_timeout ($ handle , 5 , 2 ));
40+ self ::assertSame (-1 , stream_set_write_buffer ($ handle , 0 ));
41+ self ::assertSame (0 , stream_set_read_buffer ($ handle , 0 ));
42+
43+ fclose ($ handle );
44+
45+ $ processor ->restore ();
46+ }
47+
3048 /**
3149 * @dataProvider streamOpenAppendFilterProvider
3250 */
3351 public function testStreamOpenShouldAppendFilters (bool $ expected , int $ option , ?bool $ shouldProcess = null ): void
3452 {
3553 $ mock = $ this ->getMockBuilder ('VCR\Util\StreamProcessor ' )
3654 ->disableOriginalConstructor ()
37- ->setMethods (['intercept ' , 'restore ' , 'appendFiltersToStream ' , 'shouldProcess ' ])
55+ ->onlyMethods (['intercept ' , 'restore ' , 'appendFiltersToStream ' , 'shouldProcess ' ])
3856 ->getMock ();
3957
4058 if (null !== $ shouldProcess ) {
@@ -109,8 +127,22 @@ public function testUrlStatSuccessfully(): void
109127 public function testUrlStatFileNotFound (): void
110128 {
111129 $ processor = new StreamProcessor ();
112- $ this ->expectWarning ();
113- $ processor ->url_stat ('file_not_found ' , 0 );
130+
131+ set_error_handler (static function (
132+ int $ errno ,
133+ string $ errstr ,
134+ string $ errfile = '' ,
135+ int $ errline = 0
136+ ): void {
137+ throw new \ErrorException ($ errstr , 0 , $ errno , $ errfile , $ errline );
138+ }, \E_WARNING );
139+
140+ try {
141+ $ this ->expectException (\ErrorException::class);
142+ $ processor ->url_stat ('file_not_found ' , 0 );
143+ } finally {
144+ restore_error_handler ();
145+ }
114146 }
115147
116148 /**
@@ -195,7 +227,7 @@ protected function getStreamProcessorMock()
195227 {
196228 return $ this ->getMockBuilder (StreamProcessor::class)
197229 ->disableOriginalConstructor ()
198- ->setMethods (['intercept ' , 'restore ' ])
230+ ->onlyMethods (['intercept ' , 'restore ' ])
199231 ->getMock ();
200232 }
201233}
0 commit comments