File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1905,6 +1905,20 @@ in order when requests are made::
19051905 $response1 = $client->request('...'); // returns $responses[0]
19061906 $response2 = $client->request('...'); // returns $responses[1]
19071907
1908+ It is also possible to create a
1909+ :class: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse ` directly
1910+ from a file, which is particularly useful when storing your responses
1911+ snapshots in files::
1912+
1913+ use Symfony\Component\HttpClient\Response\MockResponse;
1914+
1915+ $response = MockResponse::fromFile('tests/fixtures/response.xml');
1916+
1917+ .. versionadded :: 7.1
1918+
1919+ The :method: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse::fromFile `
1920+ method was introduced in Symfony 7.1.
1921+
19081922Another way of using :class: `Symfony\\ Component\\ HttpClient\\ MockHttpClient ` is to
19091923pass a callback that generates the responses dynamically when it's called::
19101924
@@ -2079,6 +2093,19 @@ You can use :class:`Symfony\\Component\\HttpClient\\Response\\JsonMockResponse`
20792093 'foo' => 'bar',
20802094 ]);
20812095
2096+ Just like :class: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse `, you can
2097+ also create a :class: `Symfony\\ Component\\ HttpClient\\ Response\\ JsonMockResponse `
2098+ directly from a file::
2099+
2100+ use Symfony\Component\HttpClient\Response\JsonMockResponse;
2101+
2102+ $response = JsonMockResponse::fromFile('tests/fixtures/response.json');
2103+
2104+ .. versionadded :: 7.1
2105+
2106+ The :method: `Symfony\\ Component\\ HttpClient\\ Response\\ JsonMockResponse::fromFile `
2107+ method was introduced in Symfony 7.1.
2108+
20822109Testing Request Data
20832110~~~~~~~~~~~~~~~~~~~~
20842111
You can’t perform that action at this time.
0 commit comments