Define mock responses and have mocks automatically cleared.
Resets mocked responses
Add a mock response for a DELETE request.
Add a mock response for a GET request.
Add a mock response for a PATCH request.
Add a mock response for a POST request.
Add a mock response for a PUT request.
Create a new response.
cleanupMockResponses(): void
Resets mocked responses
voidmockClientDelete(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a DELETE request.
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()
voidmockClientGet(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a GET request.
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()
voidmockClientPatch(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a PATCH request.
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()
voidmockClientPost(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a POST request.
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()
voidmockClientPut(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void
Add a mock response for a PUT request.
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()
voidnewClientResponse(int $code = 200, array<string> $headers = [], string $body = ''): Cake\Http\Client\Response
Create a new response.
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.
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