File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -1387,21 +1387,19 @@ responses dynamically when it's called::
13871387 $client = new MockHttpClient($callback);
13881388 $response = $client->request('...'); // calls $callback to get the response
13891389
1390- If you need to test your error handling with responses that have an HTTP status
1391- code different than 200, you need to provide a raw HTTP header with the
1392- `response_headers ` key::
1390+ If you need to test responses with HTTP status codes different than 200,
1391+ define the ``http_code `` option::
13931392
13941393 use Symfony\Component\HttpClient\MockHttpClient;
13951394 use Symfony\Component\HttpClient\Response\MockResponse;
13961395
13971396 $client = new MockHttpClient([
1398- new MockResponse('...', ['response_headers ' => ['HTTP/1.1 500 Internal Server Error'] ]),
1399- new MockResponse('...', ['response_headers ' => ['HTTP/1.1 404 Page Not Found'] ]),
1397+ new MockResponse('...', ['http_code ' => 500]),
1398+ new MockResponse('...', ['http_code ' => 404]),
14001399 ]);
14011400
14021401 $response = $client->request('...');
14031402
1404-
14051403The responses provided to the mock client don't have to be instances of
14061404``MockResponse ``. Any class implementing ``ResponseInterface `` will work (e.g.
14071405``$this->createMock(ResponseInterface::class) ``).
You can’t perform that action at this time.
0 commit comments