Skip to content

[HttpClient] Update http client testing section #15880

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
May 3, 2022
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
10 changes: 0 additions & 10 deletions http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1471,8 +1471,6 @@ Testing Request Data

The ``MockResponse`` class comes with some helper methods to test the request:

* ``getRequestMethod()`` - returns the HTTP method;
* ``getRequestUrl()`` - returns the URL the request would be sent to;
* ``getRequestOptions()`` - returns an array containing other information about
the request such as headers, query parameters, body content etc.

Expand All @@ -1488,12 +1486,6 @@ Usage example::
],
]);

$mockResponse->getRequestMethod();
// returns "DELETE"

$mockResponse->getRequestUrl();
// returns "https://example.com/api/article/1337"

$mockResponse->getRequestOptions()['headers'];
// returns ["Accept: */*", "Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l"]

Expand Down Expand Up @@ -1567,8 +1559,6 @@ test it in a real application::
$responseData = $service->createArticle($requestData);

// Assert
self::assertSame('POST', $mockResponse->getRequestMethod());
self::assertSame('https://example.com/api/article', $mockResponse->getRequestUrl());
self::assertContains(
'Content-Type: application/json',
$mockResponse->getRequestOptions()['headers']
Expand Down