On this page
Trait HttpClientTrait
Define mock responses and have mocks automatically cleared.
Method Summary
cleanupMockResponses() public
Resets mocked responses
mockClientDelete() public
Add a mock response for a DELETE request.
mockClientGet() public
Add a mock response for a GET request.
mockClientPatch() public
Add a mock response for a PATCH request.
mockClientPost() public
Add a mock response for a POST request.
mockClientPut() public
Add a mock response for a PUT request.
newClientResponse() public
Create a new response.
Method Detail
cleanupMockResponses() public
cleanupMockResponses(): void
Resets mocked responses
Returns
voidmockClientDelete() public
mockClientDelete(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a DELETE request.
Parameters
string$url-
The URL to mock
Cake\Http\Client\Response$response-
The response for the mock.
array<string, mixed>$options optional-
Additional options. See Client::addMockResponse()
Returns
voidmockClientGet() public
mockClientGet(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a GET request.
Parameters
string$url-
The URL to mock
Cake\Http\Client\Response$response-
The response for the mock.
array<string, mixed>$options optional-
Additional options. See Client::addMockResponse()
Returns
voidmockClientPatch() public
mockClientPatch(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a PATCH request.
Parameters
string$url-
The URL to mock
Cake\Http\Client\Response$response-
The response for the mock.
array<string, mixed>$options optional-
Additional options. See Client::addMockResponse()
Returns
voidmockClientPost() public
mockClientPost(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a POST request.
Parameters
string$url-
The URL to mock
Cake\Http\Client\Response$response-
The response for the mock.
array<string, mixed>$options optional-
Additional options. See Client::addMockResponse()
Returns
voidmockClientPut() public
mockClientPut(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a PUT request.
Parameters
string$url-
The URL to mock
Cake\Http\Client\Response$response-
The response for the mock.
array<string, mixed>$options optional-
Additional options. See Client::addMockResponse()
Returns
voidnewClientResponse() public
newClientResponse(int $code = 200, array<string> $headers = [], string $body = ''): Cake\Http\Client\Response
Create a new response.
Parameters
int$code optional-
The response code to use. Defaults to 200
array<string>$headers optional-
A list of headers for the response. Example
Content-Type: application/json string$body optional-
The body for the response.
Returns
Cake\Http\Client\Response© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/trait-Cake.Http.TestSuite.HttpClientTrait.html