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 ' :
@@ -295,12 +286,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
295286 break ;
296287
297288 case 'testTimeoutOnAccess ' :
298- $ mock = $ this ->createMock (ResponseInterface::class);
299- $ mock ->expects ($ this ->any ())
300- ->method ('getHeaders ' )
301- ->willThrowException (new TransportException ('Timeout ' ));
302-
303- $ responses [] = $ mock ;
289+ $ responses [] = new MockResponse ('' , ['error ' => 'Timeout ' ]);
304290 break ;
305291
306292 case 'testAcceptHeader ' :
@@ -362,16 +348,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
362348 break ;
363349
364350 case 'testMaxDuration ' :
365- $ mock = $ this ->createMock (ResponseInterface::class);
366- $ mock ->expects ($ this ->any ())
367- ->method ('getContent ' )
368- ->willReturnCallback (static function (): void {
369- usleep (100000 );
370-
371- throw new TransportException ('Max duration was reached. ' );
372- });
373-
374- $ responses [] = $ mock ;
351+ $ responses [] = new MockResponse ('' , ['error ' => 'Max duration was reached. ' ]);
375352 break ;
376353 }
377354
0 commit comments