File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff 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+
16811698If you need to test responses with HTTP status codes different than 200,
16821699define the ``http_code `` option::
16831700
You can’t perform that action at this time.
0 commit comments