Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 59f7564

Browse filesBrowse files
committed
[HttpClient] Add method to set response factory in mock client
1 parent ea5b632 commit 59f7564
Copy full SHA for 59f7564

File tree

2 files changed

+14
-1
lines changed
Filter options

2 files changed

+14
-1
lines changed

‎src/Symfony/Component/HttpClient/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.4
5+
---
6+
7+
* Add `MockHttpClient::setResponseFactory()` method to be able to set response factory after client creating
8+
49
5.3
510
---
611

‎src/Symfony/Component/HttpClient/MockHttpClient.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/MockHttpClient.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ class MockHttpClient implements HttpClientInterface
3535
* @param callable|callable[]|ResponseInterface|ResponseInterface[]|iterable|null $responseFactory
3636
*/
3737
public function __construct($responseFactory = null, ?string $baseUri = 'https://example.com')
38+
{
39+
$this->setResponseFactory($responseFactory);
40+
$this->defaultOptions['base_uri'] = $baseUri;
41+
}
42+
43+
/**
44+
* @param callable|callable[]|ResponseInterface|ResponseInterface[]|iterable|null $responseFactory
45+
*/
46+
public function setResponseFactory($responseFactory)
3847
{
3948
if ($responseFactory instanceof ResponseInterface) {
4049
$responseFactory = [$responseFactory];
@@ -47,7 +56,6 @@ public function __construct($responseFactory = null, ?string $baseUri = 'https:/
4756
}
4857

4958
$this->responseFactory = $responseFactory;
50-
$this->defaultOptions['base_uri'] = $baseUri;
5159
}
5260

5361
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.