8000 [FrameworkBundle] Add HttpClientAssertions trait documentation by welcoMattic · Pull Request #18970 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Add HttpClientAssertions trait documentation #18970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,31 @@ Notifier Assertions

The Notifier assertions were introduced in Symfony 6.2.

HttpClient Assertions
.....................

.. tip::

For all following assertions, ``$client->enableProfiler()`` must be called before the code that will trigger HTTP request(s).

``assertHttpClientRequest(string $expectedUrl, string $expectedMethod = 'GET', string|array $expectedBody = null, array $expectedHeaders = [], string $httpClientId = 'http_client')``
Asserts that the given URL has been called using, is specified,
the given method body and headers. By default it will check on the HttpClient,
but a HttpClient id can be specified.
(It will succeed if the request has been called multiple times.)

``assertNotHttpClientRequest(string $unexpectedUrl, string $expectedMethod = 'GET', string $httpClientId = 'http_client')``
Asserts that the given URL has not been called using GET or the specified method.
By default it will check on the HttpClient, but a HttpClient id can be specified.

``assertHttpClientRequestCount(int $count, string $httpClientId = 'http_client')``
Asserts that the given number of requests has been made on the HttpClient.
By default it will check on the HttpClient, but a HttpClient id can be specified.

.. versionadded:: 6.4

The HttpClient assertions were introduced in Symfony 6.4.

.. TODO
.. End to End Tests (E2E)
.. ----------------------
Expand Down
0