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{
@@ -141,16 +140,8 @@ protected function getHttpClient(string $testCase): HttpClientInterface
141140 break ;
142141
143142 case 'testDnsError ' :
144- $ mock = $ this ->createMock (ResponseInterface::class);
145- $ mock ->expects ($ this ->any ())
146- ->method ('getStatusCode ' )
147- ->willThrowException (new TransportException ('DSN error ' ));
148- $ mock ->expects ($ this ->any ())
149- ->method ('getInfo ' )
150- ->willReturn ([]);
151-
152- $ responses [] = $ mock ;
153- $ responses [] = $ mock ;
143+ $ responses [] = $ mockResponse = new MockResponse ('' , ['error ' => 'DNS error ' ]);
144+ $ responses [] = $ mockResponse ;
154145 break ;
155146
156147 case 'testToStream ' :
@@ -164,12 +155,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
164155 break ;
165156
166157 case 'testTimeoutOnAccess ' :
167- $ mock = $ this ->createMock (ResponseInterface::class);
168- $ mock ->expects ($ this ->any ())
169- ->method ('getHeaders ' )
170- ->willThrowException (new TransportException ('Timeout ' ));
171-
172- $ responses [] = $ mock ;
158+ $ responses [] = new MockResponse ('' , ['error ' => 'Timeout ' ]);
173159 break ;
174160
175161 case 'testAcceptHeader ' :
@@ -231,16 +217,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
231217 break ;
232218
233219 case 'testMaxDuration ' :
234- $ mock = $ this ->createMock (ResponseInterface::class);
235- $ mock ->expects ($ this ->any ())
236- ->method ('getContent ' )
237- ->willReturnCallback (static function (): void {
238- usleep (100000 );
239-
240- throw new TransportException ('Max duration was reached. ' );
241- });
242-
243- $ responses [] = $ mock ;
220+ $ responses [] = new MockResponse ('' , ['error ' => 'Max duration was reached. ' ]);
244221 break ;
245222 }
246223
0 commit comments