8000 [HttpClient] Allow mocking start_time info in MockResponse · symfony/symfony@7ace621 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ace621

Browse files
committed
[HttpClient] Allow mocking start_time info in MockResponse
1 parent dc330b0 commit 7ace621

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/Symfony/Component/HttpClient/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.1
5+
---
6+
7+
* Allow mocking `start_time` info in `MockResponse`
8+
49
7.0
510
---
611

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 (null !== $mock->getInfo('start_time')) {
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)
0