|
12 | 12 | namespace Symfony\Component\HttpClient\Tests\DataCollector; |
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\HttpClient\CurlHttpClient; |
15 | 16 | use Symfony\Component\HttpClient\DataCollector\HttpClientDataCollector; |
| 17 | +use Symfony\Component\HttpClient\Exception\TransportException; |
16 | 18 | use Symfony\Component\HttpClient\MockHttpClient; |
17 | 19 | use Symfony\Component\HttpClient\NativeHttpClient; |
18 | 20 | use Symfony\Component\HttpClient\TraceableHttpClient; |
@@ -427,6 +429,27 @@ public function testItDoesNotGeneratesCurlCommandsForUploadedFiles() |
427 | 429 | self::assertNull($curlCommand); |
428 | 430 | } |
429 | 431 |
|
| 432 | + /** |
| 433 | + * @requires extension curl |
| 434 | + */ |
| 435 | + public function testGeneratingCurlCommandForArraysWithResourcesAndUnreachableHost() |
| 436 | + { |
| 437 | + $httpClient = new TraceableHttpClient(new CurlHttpClient()); |
| 438 | + try { |
| 439 | + $httpClient->request('POST', 'http://localhast:8057/', [ |
| 440 | + 'body' => ['file' => fopen('data://text/plain,', 'r')], |
| 441 | + ]); |
| 442 | + } catch (TransportException) { |
| 443 | + } |
| 444 | + $sut = new HttpClientDataCollector(); |
| 445 | + $sut->registerClient('http_client', $httpClient); |
| 446 | + $sut->lateCollect(); |
| 447 | + $collectedData = $sut->getClients(); |
| 448 | + self::assertCount(1, $collectedData['http_client']['traces']); |
| 449 | + $curlCommand = $collectedData['http_client']['traces'][0]['curlCommand']; |
| 450 | + self::assertNull($curlCommand); |
| 451 | + } |
| 452 | + |
430 | 453 | private function httpClientThatHasTracedRequests($tracedRequests): TraceableHttpClient |
431 | 454 | { |
432 | 455 | $httpClient = new TraceableHttpClient(new NativeHttpClient()); |
|
0 commit comments