1818use Symfony \Component \HttpClient \Response \ResponseStream ;
1919use Symfony \Contracts \HttpClient \ChunkInterface ;
2020use Symfony \Contracts \HttpClient \HttpClientInterface ;
21- use Symfony \Contracts \HttpClient \ResponseInterface ;
2221
2322class MockHttpClientTest extends HttpClientTestCase
2423{
@@ -272,16 +271,8 @@ protected function getHttpClient(string $testCase): HttpClientInterface
272271 break ;
273272
274273 case 'testDnsError ' :
275- $ mock = $ this ->createMock (ResponseInterface::class);
276- $ mock ->expects ($ this ->any ())
277- ->method ('getStatusCode ' )
278- ->willThrowException (new TransportException ('DSN error ' ));
279- $ mock ->expects ($ this ->any ())
280- ->method ('getInfo ' )
281- ->willReturn ([]);
282-
283- $ responses [] = $ mock ;
284- $ responses [] = $ mock ;
274+ $ responses [] = $ mockResponse = new MockResponse ('' , ['error ' => 'DNS error ' ]);
275+ $ responses [] = $ mockResponse ;
285276 break ;
286277
287278 case 'testToStream ' :
@@ -296,12 +287,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
296287 break ;
297288
298289 case 'testTimeoutOnAccess ' :
299- $ mock = $ this ->createMock (ResponseInterface::class);
300- $ mock ->expects ($ this ->any ())
301- ->method ('getHeaders ' )
302- ->willThrowException (new TransportException ('Timeout ' ));
303-
304- $ responses [] = $ mock ;
290+ $ responses [] = new MockResponse ('' , ['error ' => 'Timeout ' ]);
305291 break ;
306292
307293 case 'testAcceptHeader ' :
@@ -363,16 +349,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
363349 break ;
364350
365351 case 'testMaxDuration ' :
366- $ mock = $ this ->createMock (ResponseInterface::class);
367- $ mock ->expects ($ this ->any ())
368- ->method ('getContent ' )
369- ->willReturnCallback (static function (): void {
370- usleep (100000 );
371-
372- throw new TransportException ('Max duration was reached. ' );
373- });
374-
375- $ responses [] = $ mock ;
352+ $ responses [] = new MockResponse ('' , ['error ' => 'Max duration was reached. ' ]);
376353 break ;
377354 }
378355
0 commit comments