mediatekformation

MockResponse
in package
implements ResponseInterface Uses ResponseTrait

A test-friendly response.

Tags
author

Nicolas Grekas p@tchwork.com

Interfaces, Classes, Traits and Enums

ResponseInterface
A (lazily retrieved) HTTP response.

Table of Contents

$body  : mixed
$idSequence  : mixed
$mainMulti  : mixed
$requestOptions  : mixed
__construct()  : mixed
cancel()  : void
Closes the response stream and all related buffers.
getInfo()  : mixed
Returns info coming from the transport layer.
getRequestOptions()  : array<string|int, mixed>
Returns the options used when doing the request.
close()  : void
{@inheritdoc}
perform()  : void
{@inheritdoc}
schedule()  : void
{@inheritdoc}
select()  : int
{@inheritdoc}
readResponse()  : mixed
Simulates reading the response.
writeRequest()  : mixed
Simulates sending the request.

Properties

Methods

__construct()

public __construct([string|array<string|int, string>|iteratable<string|int, mixed> $body = '' ][, array<string|int, mixed> $info = [] ]) : mixed
Parameters
$body : string|array<string|int, string>|iteratable<string|int, mixed> = ''

The response body as a string or an iterable of strings, yielding an empty string simulates an idle timeout, exceptions are turned to TransportException

$info : array<string|int, mixed> = []
Tags
see
ResponseInterface::getInfo()

for possible info, e.g. "response_headers"

Return values
mixed

cancel()

Closes the response stream and all related buffers.

public cancel() : void
Return values
void

getInfo()

Returns info coming from the transport layer.

public getInfo([string $type = null ]) : mixed
Parameters
$type : string = 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

getRequestOptions()

Returns the options used when doing the request.

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

close()

{@inheritdoc}

protected close() : void
Return values
void

perform()

{@inheritdoc}

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

schedule()

{@inheritdoc}

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

select()

{@inheritdoc}

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

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
Return values
mixed

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
Return values
mixed

Search results