Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b331989

Browse files
committed
minor #18970 [FrameworkBundle] Add HttpClientAssertions trait documentation (welcoMattic)
This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle] Add HttpClientAssertions trait documentation Ref symfony/symfony#50662 Commits ------- caa3483 Add HttpClientAssertions trait documentation
2 parents e2be3c3 + caa3483 commit b331989

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

testing.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,31 @@ Notifier Assertions
11441144

11451145
The Notifier assertions were introduced in Symfony 6.2.
11461146

1147+
HttpClient Assertions
1148+
.....................
1149+
1150+
.. tip::
1151+
1152+
For all following assertions, ``$client->enableProfiler()`` must be called before the code that will trigger HTTP request(s).
1153+
1154+
``assertHttpClientRequest(string $expectedUrl, string $expectedMethod = 'GET', string|array $expectedBody = null, array $expectedHeaders = [], string $httpClientId = 'http_client')``
1155+
Asserts that the given URL has been called using, is specified,
1156+
the given method body and headers. By default it will check on the HttpClient,
1157+
but a HttpClient id can be specified.
1158+
(It will succeed if the request has been called multiple times.)
1159+
1160+
``assertNotHttpClientRequest(string $unexpectedUrl, string $expectedMethod = 'GET', string $httpClientId = 'http_client')``
1161+
Asserts that the given URL has not been called using GET or the specified method.
1162+
By default it will check on the HttpClient, but a HttpClient id can be specified.
1163+
1164+
``assertHttpClientRequestCount(int $count, string $httpClientId = 'http_client')``
1165+
Asserts that the given number of requests has been made on the HttpClient.
1166+
By default it will check on the HttpClient, but a HttpClient id can be specified.
1167+
1168+
.. versionadded:: 6.4
1169+
1170+
The HttpClient assertions were introduced in Symfony 6.4.
1171+
11471172
.. TODO
11481173
.. End to End Tests (E2E)
11491174
.. ----------------------

0 commit comments

Comments
 (0)