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::
1905
1905
$response1 = $client->request('...'); // returns $responses[0]
1906
1906
$response2 = $client->request('...'); // returns $responses[1]
1907
1907
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
+
1908
1922
Another way of using :class: `Symfony\\ Component\\ HttpClient\\ MockHttpClient ` is to
1909
1923
pass a callback that generates the responses dynamically when it's called::
1910
1924
@@ -2079,6 +2093,19 @@ You can use :class:`Symfony\\Component\\HttpClient\\Response\\JsonMockResponse`
2079
2093
'foo' => 'bar',
2080
2094
]);
2081
2095
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
+
2082
2109
Testing Request Data
2083
2110
~~~~~~~~~~~~~~~~~~~~
2084
2111
You can’t perform that action at this time.
0 commit comments