diff --git a/testing.rst b/testing.rst index 4c8db86ad08..a00a60c9ed2 100644 --- a/testing.rst +++ b/testing.rst @@ -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) .. ----------------------