Documentation

Mock
in package
implements ClientInterface

Mock HTTP client object. Derived from the original Mock Http Request.

Tags
author

Chuck Hagenbuch chuck@horde.org

author

Gunnar Wrobel wrobel@pardus.de

category

Horde

copyright

2007-2017 Horde LLC

license

http://www.horde.org/licenses/bsd BSD

Interfaces, Classes, Traits and Enums

ClientInterface

Table of Contents

$responseFactory  : ResponseFactoryInterface
$responses  : array<string|int, mixed>
Mock responses to return.
$streamFactory  : StreamFactoryInterface
__construct()  : mixed
addResponse()  : Response
Adds a response to the stack of responses.
addResponses()  : void
Set the HTTP response(s) to be returned by this adapter as an array Response objects.
sendRequest()  : ResponseInterface
Actually send a request
setResponse()  : mixed
Set the HTTP response(s) to be returned by this adapter. This overwrites any responses set before.

Properties

$responseFactory

protected ResponseFactoryInterface $responseFactory

$responses

Mock responses to return.

protected array<string|int, mixed> $responses = []

$streamFactory

protected StreamFactoryInterface $streamFactory

Methods

__construct()

public __construct([ResponseFactoryInterface $responseFactory = null ][, StreamFactoryInterface $streamFactory = null ][, Options $options = null ]) : mixed
Parameters
$responseFactory : ResponseFactoryInterface = null
$streamFactory : StreamFactoryInterface = null
$options : Options = null
Return values
mixed —

addResponse()

Adds a response to the stack of responses.

public addResponse(string|resourse $body[, string $code = 200 ][, string $uri = '' ][, array<string|int, mixed> $headers = [] ]) : Response
Parameters
$body : string|resourse

The response body content.

$code : string = 200

The response code.

$uri : string = ''

The request uri.

$headers : array<string|int, mixed> = []

Response headers. This can be one string representing the whole header or an array of strings with one string per header line.

Return values
Response —

The response.

addResponses()

Set the HTTP response(s) to be returned by this adapter as an array Response objects.

public addResponses(iteratable<string|int, mixed> $responses) : void
Parameters
$responses : iteratable<string|int, mixed>

The responses to be added to the stack.

Return values
void —

sendRequest()

Actually send a request

public sendRequest(RequestInterface $request) : ResponseInterface
Parameters
$request : RequestInterface
Return values
ResponseInterface —

setResponse()

Set the HTTP response(s) to be returned by this adapter. This overwrites any responses set before.

public setResponse(mixed $responses) : mixed
Parameters
$responses : mixed
Return values
mixed —

Search results