class MockResponse extends FakeResponse

Traits

Properties

protected BodyRepository $body

The response body.

from  FakeResponse
protected null|Throwable $responseException

The configured exception resolver.

from  FakeResponse

Methods

static static
make(array|string $body = '[]', int $status = '200', array<string $, mixed> $headers = '[]')

No description

__construct(array|string $body = [], int $status = 200, array $headers = [])

Create a fake response.

body()

Get the response body repository.

int
status()

Get the response status.

array
headers()

Get the response headers.

throw(Closure|Throwable $value)

Configure an exception for the request.

Throwable|null
getException(PendingRequest $pendingRequest)

Resolve the configured exception.

static Fixture
fixture(string $name)

Create a fake response from a fixture.

ResponseInterface
createPsrResponse()

Create the PSR response.

Details

at line 10
static static make(array|string $body = '[]', int $status = '200', array<string $, mixed> $headers = '[]')

No description

Parameters

array|string $body
int $status
array<string $
mixed> $headers

Return Value

static

in FakeResponse at line 44
__construct(array|string $body = [], int $status = 200, array $headers = [])

Create a fake response.

Parameters

array|string $body
int $status
array $headers

in FakeResponse at line 57
BodyRepository body()

Get the response body repository.

Return Value

BodyRepository

in FakeResponse at line 65
int status()

Get the response status.

Return Value

int

in FakeResponse at line 75
array headers()

Get the response headers.

Return Value

array

in FakeResponse at line 85
FakeResponse throw(Closure|Throwable $value)

Configure an exception for the request.

Parameters

Closure|Throwable $value

Return Value

FakeResponse

in FakeResponse at line 97
Throwable|null getException(PendingRequest $pendingRequest)

Resolve the configured exception.

Parameters

PendingRequest $pendingRequest

Return Value

Throwable|null

in FakeResponse at line 107
static Fixture fixture(string $name)

Create a fake response from a fixture.

Parameters

string $name

Return Value

Fixture

in FakeResponse at line 115
ResponseInterface createPsrResponse()

Create the PSR response.

Return Value

ResponseInterface