HumHub Documentation (unofficial)

SimpleMockedResponse extends MockResponse
in package

A test-friendly response.

Tags
final

Table of Contents

Properties

$body  : mixed
$content  : string
$headers  : array<string, array<int, string>>
$idSequence  : mixed
$mainMulti  : mixed
$requestMethod  : mixed
$requestOptions  : mixed
$requestUrl  : mixed
$statusCode  : int

Methods

__construct()  : mixed
cancel()  : void
Closes the response stream and all related buffers.
getContent()  : string
Gets the response body as a string.
getHeaders()  : array<string|int, array<string|int, string>>
Gets the HTTP headers of the response.
getInfo()  : mixed
Returns info coming from the transport layer.
getRequestMethod()  : string
Returns the method used when doing the request.
getRequestOptions()  : array<string|int, mixed>
Returns the options used when doing the request.
getRequestUrl()  : string
Returns the URL used when doing the request.
getStatusCode()  : int
Gets the HTTP status code of the response.
toArray()  : array<string, mixed>
Gets the response body decoded as array, typically from a JSON payload.
close()  : void
{@inheritdoc}
perform()  : void
{@inheritdoc}
schedule()  : void
{@inheritdoc}
select()  : int
{@inheritdoc}
getFlatHeaders()  : array<int, string>
readResponse()  : mixed
Simulates reading the response.
writeRequest()  : mixed
Simulates sending the request.

Properties

Methods

__construct()

public __construct([string $content = '' ][, array<string, string|array<int, string>> $headers = [] ][, int $statusCode = 200 ]) : mixed
Parameters
$content : string = ''
$headers : array<string, string|array<int, string>> = []

['name'=>'value'] OR ['name'=>['value']]

$statusCode : int = 200

getContent()

Gets the response body as a string.

public getContent([bool $throw = true ]) : string
Parameters
$throw : bool = true

Whether an exception should be thrown on 3/4/5xx status codes

Return values
string

getHeaders()

Gets the HTTP headers of the response.

public getHeaders([bool $throw = true ]) : array<string|int, array<string|int, string>>
Parameters
$throw : bool = true

Whether an exception should be thrown on 3/4/5xx status codes

Return values
array<string|int, array<string|int, string>>

The headers of the response keyed by header names in lowercase

getInfo()

Returns info coming from the transport layer.

public getInfo([string|null $type = null ]) : mixed
Parameters
$type : string|null = null
Return values
mixed

An array of all available info, or one of them when $type is provided, or null when an unsupported type is requested

getRequestMethod()

Returns the method used when doing the request.

public getRequestMethod() : string
Return values
string

getRequestOptions()

Returns the options used when doing the request.

public getRequestOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRequestUrl()

Returns the URL used when doing the request.

public getRequestUrl() : string
Return values
string

getStatusCode()

Gets the HTTP status code of the response.

public getStatusCode() : int
Return values
int

toArray()

Gets the response body decoded as array, typically from a JSON payload.

public toArray([bool $throw = true ]) : array<string, mixed>
Parameters
$throw : bool = true

Whether an exception should be thrown on 3/4/5xx status codes

Return values
array<string, mixed>

perform()

{@inheritdoc}

protected static perform(ClientState $multi, array<string|int, mixed> &$responses) : void
Parameters
$multi : ClientState
$responses : array<string|int, mixed>

schedule()

{@inheritdoc}

protected static schedule(self $response, array<string|int, mixed> &$runningResponses) : void
Parameters
$response : self
$runningResponses : array<string|int, mixed>

select()

{@inheritdoc}

protected static select(ClientState $multi, float $timeout) : int
Parameters
$multi : ClientState
$timeout : float
Return values
int

getFlatHeaders()

private getFlatHeaders() : array<int, string>
Return values
array<int, string>

readResponse()

Simulates reading the response.

private static readResponse(self $response, array<string|int, mixed> $options, ResponseInterface $mock, int &$offset) : mixed
Parameters
$response : self
$options : array<string|int, mixed>
$mock : ResponseInterface
$offset : int

writeRequest()

Simulates sending the request.

private static writeRequest(self $response, array<string|int, mixed> $options, ResponseInterface $mock) : mixed
Parameters
$response : self
$options : array<string|int, mixed>
$mock : ResponseInterface

        
On this page

Search results