Class Mock
Implements sending requests to an array of stubbed responses
This adapter is not intended for production use. Instead
it is the backend used by Client::addMockResponse()
Namespace: Cake\Http\Client\Adapter
Property Summary
-
$responses protected
array
List of mocked responses.
Method Summary
-
addResponse() public
Add a mocked response.
-
send() public
Find a response if one exists.
-
urlMatches() protected
Check if the request URI matches the mock URI.
Method Detail
addResponse() ¶ public
addResponse(Psr\Http\Message\RequestInterface $request, Cake\Http\Client\Response $response, array<string, mixed> $options): void
Add a mocked response.
Options
match
An additional closure to match requests with.
Parameters
-
Psr\Http\Message\RequestInterface
$request A partial request to use for matching.
-
Cake\Http\Client\Response
$response The response that matches the request.
-
array<string, mixed>
$options See above.
Returns
void
send() ¶ public
send(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): Cake\Http\Client\Response[]
Find a response if one exists.
Parameters
-
Psr\Http\Message\RequestInterface
$request The request to match
-
array<string, mixed>
$options Unused.
Returns
Cake\Http\Client\Response[]
urlMatches() ¶ protected
urlMatches(string $requestUri, Psr\Http\Message\RequestInterface $mock): bool
Check if the request URI matches the mock URI.
Parameters
-
string
$requestUri The request being sent.
-
Psr\Http\Message\RequestInterface
$mock The request being mocked.
Returns
bool