Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit76bd5fb

Browse files
greeflaswouterj
authored andcommitted
[HttpClient] HttpClientInterface::setResponseFactory method
1 parent14d05b1 commit76bd5fb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎http_client.rst‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,23 @@ responses dynamically when it's called::
16781678
$client = new MockHttpClient($callback);
16791679
$response = $client->request('...'); // calls $callback to get the response
16801680

1681+
..tip::
1682+
1683+
Instead of using the first argument, you can also set the (list of)
1684+
responses or callbacks using the ``setResponseFactory()`` method::
1685+
1686+
$responses = [
1687+
new MockResponse($body1, $info1),
1688+
new MockResponse($body2, $info2),
1689+
];
1690+
1691+
$client = new MockHttpClient();
1692+
$client->setResponseFactory($responses);
1693+
1694+
..versionadded::5.4
1695+
1696+
The ``setResponseFactory()`` method was introduced in Symfony 5.4.
1697+
16811698
If you need to test responses with HTTP status codes different than 200,
16821699
define the ``http_code`` option::
16831700

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp