Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c5d797

Browse files
committed
[HttpClient] Allow mocking start_time info in MockResponse
1 parent c8b962a commit 3c5d797

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Symfony/Component/HttpClient/Response/MockResponse.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ private static function writeRequest(self $response, array $options, ResponseInt
217217
{
218218
$onProgress = $options['on_progress'] ?? static function () {};
219219
$response->info += $mock->getInfo() ?: [];
220+
if ($mock->getInfo('start_time') !== null) {
221+
$response->info['start_time'] = $mock->getInfo('start_time');
222+
}
220223

221224
// simulate "size_upload" if it is set
222225
if (isset($response->info['size_upload'])) {

src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,4 +573,14 @@ public function testMoreRequestsThanResponseFactoryResponses()
573573
$client->request('GET', 'https://example.com');
574574
$client->request('GET', 'https://example.com');
575575
}
576+
577+
public function testMockStartTimeInfo()
578+
{
579+
$client = new MockHttpClient(new MockResponse('foobarccc', [
580+
'start_time' => 1701187598.313123,
581+
]));
582+
583+
$response = $client->request('GET', 'https://example.com');
584+
$this->assertSame(1701187598.313123, $response->getInfo('start_time'));
585+
}
576586
}

0 commit comments

Comments
 (0)