MockResponse
in package
implements
ResponseInterface, StreamableInterface
uses
CommonResponseTrait, TransportResponseTrait
A test-friendly response.
Tags
Table of Contents
Interfaces
- ResponseInterface
- A (lazily retrieved) HTTP response.
- StreamableInterface
Properties
- $body : mixed
- $idSequence : mixed
- $mainMulti : mixed
- $requestMethod : mixed
- $requestOptions : mixed
- $requestUrl : mixed
Methods
- __construct() : mixed
- cancel() : void
- Closes the response stream and all related buffers.
- 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.
- 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
$body
private
mixed
$body
$idSequence
private
static mixed
$idSequence
= 0
$mainMulti
private
static mixed
$mainMulti
$requestMethod
private
mixed
$requestMethod
$requestOptions
private
mixed
$requestOptions
= []
$requestUrl
private
mixed
$requestUrl
Methods
__construct()
public
__construct([string|array<string|int, string>|iterable<string|int, mixed> $body = '' ][, array<string|int, mixed> $info = [] ]) : mixed
Parameters
- $body : string|array<string|int, string>|iterable<string|int, mixed> = ''
-
The response body as a string or an iterable of strings, yielding an empty string simulates an idle timeout, throwing an exception yields an ErrorChunk
- $info : array<string|int, mixed> = []
Tags
cancel()
Closes the response stream and all related buffers.
public
cancel() : void
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
stringgetRequestOptions()
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
stringclose()
{@inheritdoc}
protected
close() : void
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
intreadResponse()
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