class TestResponse mixin Response

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
Response $baseResponse

The response to delegate to.

Methods

static void
macro(string $name, callable $macro)

Register a custom macro.

static bool
hasMacro(string $name)

Checks if macro is registered.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $args)

Handle dynamic calls into macros or pass missing methods to the base response.

void
__construct(Response $response)

Create a new test response instance.

static TestResponse
fromBaseResponse(Response $response)

Create a new TestResponse from another response.

$this
assertSuccessful()

Assert that the response has a successful status code.

$this
assertStatus(int $status)

Assert that the response has the given status code.

$this
assertRedirect(string $uri = null)

Assert whether the response is redirecting to a given URI.

$this
assertHeader(string $headerName, mixed $value = null)

Asserts that the response contains the given header and equals the optional value.

$this
assertPlainCookie(string $cookieName, mixed $value = null)

Asserts that the response contains the given cookie and equals the optional value.

$this
assertCookie(string $cookieName, mixed $value = null, bool $encrypted = true)

Asserts that the response contains the given cookie and equals the optional value.

Cookie|null
getCookie(string $cookieName)

Get the given cookie from the response.

$this
assertSee(string $value)

Assert that the given string is contained within the response.

$this
assertSeeText(string $value)

Assert that the given string is contained within the response text.

$this
assertDontSee(string $value)

Assert that the given string is not contained within the response.

$this
assertDontSeeText(string $value)

Assert that the given string is not contained within the response text.

$this
assertJson(array $data)

Assert that the response is a superset of the given JSON.

string
assertJsonMessage(array $data)

Get the assertion message for assertJson.

$this
assertExactJson(array $data)

Assert that the response has the exact given JSON.

$this
assertJsonFragment(array $data)

Assert that the response contains the given JSON fragment.

$this
assertJsonMissing(array $data)

Assert that the response does not contain the given JSON fragment.

$this
assertJsonStructure(array $structure = null, array|null $responseData = null)

Assert that the response has a given JSON structure.

array
decodeResponseJson()

Validate and return the decoded response JSON.

array
json()

Validate and return the decoded response JSON.

$this
assertViewIs(string $value)

Assert that the response view equals the given value.

$this
assertViewHas(string|array $key, mixed $value = null)

Assert that the response view has a given piece of bound data.

$this
assertViewHasAll(array $bindings)

Assert that the response view has a given list of bound data.

$this
assertViewMissing(string $key)

Assert that the response view is missing a piece of bound data.

$this
ensureResponseHasView()

Ensure that the response has a view as its original content.

$this
assertSessionHas(string|array $key, mixed $value = null)

Assert that the session has a given value.

$this
assertSessionHasAll(array $bindings)

Assert that the session has a given list of values.

$this
assertSessionHasErrors(string|array $keys = [], mixed $format = null)

Assert that the session has the given errors.

$this
assertSessionMissing(string|array $key)

Assert that the session does not have a given key.

session()

Get the current session store.

void
dump()

Dump the content from the response.

mixed
__get(string $key)

Dynamically access base response parameters.

mixed
__isset(string $key)

Proxy isset() checks to the underlying base response.

Details

in Macroable at line 24
static void macro(string $name, callable $macro)

Register a custom macro.

Parameters

string $name
callable $macro

Return Value

void

in Macroable at line 35
static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 49
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 649
mixed __call(string $method, array $args)

Handle dynamic calls into macros or pass missing methods to the base response.

Parameters

string $method
array $args

Return Value

mixed

at line 35
void __construct(Response $response)

Create a new test response instance.

Parameters

Response $response

Return Value

void

at line 46
static TestResponse fromBaseResponse(Response $response)

Create a new TestResponse from another response.

Parameters

Response $response

Return Value

TestResponse

at line 56
$this assertSuccessful()

Assert that the response has a successful status code.

Return Value

$this

at line 72
$this assertStatus(int $status)

Assert that the response has the given status code.

Parameters

int $status

Return Value

$this

at line 90
$this assertRedirect(string $uri = null)

Assert whether the response is redirecting to a given URI.

Parameters

string $uri

Return Value

$this

at line 110
$this assertHeader(string $headerName, mixed $value = null)

Asserts that the response contains the given header and equals the optional value.

Parameters

string $headerName
mixed $value

Return Value

$this

at line 135
$this assertPlainCookie(string $cookieName, mixed $value = null)

Asserts that the response contains the given cookie and equals the optional value.

Parameters

string $cookieName
mixed $value

Return Value

$this

at line 150
$this assertCookie(string $cookieName, mixed $value = null, bool $encrypted = true)

Asserts that the response contains the given cookie and equals the optional value.

Parameters

string $cookieName
mixed $value
bool $encrypted

Return Value

$this

at line 180
protected Cookie|null getCookie(string $cookieName)

Get the given cookie from the response.

Parameters

string $cookieName

Return Value

Cookie|null

at line 195
$this assertSee(string $value)

Assert that the given string is contained within the response.

Parameters

string $value

Return Value

$this

at line 208
$this assertSeeText(string $value)

Assert that the given string is contained within the response text.

Parameters

string $value

Return Value

$this

at line 221
$this assertDontSee(string $value)

Assert that the given string is not contained within the response.

Parameters

string $value

Return Value

$this

at line 234
$this assertDontSeeText(string $value)

Assert that the given string is not contained within the response text.

Parameters

string $value

Return Value

$this

at line 247
$this assertJson(array $data)

Assert that the response is a superset of the given JSON.

Parameters

array $data

Return Value

$this

at line 262
protected string assertJsonMessage(array $data)

Get the assertion message for assertJson.

Parameters

array $data

Return Value

string

at line 280
$this assertExactJson(array $data)

Assert that the response has the exact given JSON.

Parameters

array $data

Return Value

$this

at line 297
$this assertJsonFragment(array $data)

Assert that the response contains the given JSON fragment.

Parameters

array $data

Return Value

$this

at line 324
$this assertJsonMissing(array $data)

Assert that the response does not contain the given JSON fragment.

Parameters

array $data

Return Value

$this

at line 352
$this assertJsonStructure(array $structure = null, array|null $responseData = null)

Assert that the response has a given JSON structure.

Parameters

array $structure
array|null $responseData

Return Value

$this

at line 386
array decodeResponseJson()

Validate and return the decoded response JSON.

Return Value

array

at line 406
array json()

Validate and return the decoded response JSON.

Return Value

array

at line 417
$this assertViewIs(string $value)

Assert that the response view equals the given value.

Parameters

string $value

Return Value

$this

at line 433
$this assertViewHas(string|array $key, mixed $value = null)

Assert that the response view has a given piece of bound data.

Parameters

string|array $key
mixed $value

Return Value

$this

at line 458
$this assertViewHasAll(array $bindings)

Assert that the response view has a given list of bound data.

Parameters

array $bindings

Return Value

$this

at line 477
$this assertViewMissing(string $key)

Assert that the response view is missing a piece of bound data.

Parameters

string $key

Return Value

$this

at line 491
protected $this ensureResponseHasView()

Ensure that the response has a view as its original content.

Return Value

$this

at line 507
$this assertSessionHas(string|array $key, mixed $value = null)

Assert that the session has a given value.

Parameters

string|array $key
mixed $value

Return Value

$this

at line 531
$this assertSessionHasAll(array $bindings)

Assert that the session has a given list of values.

Parameters

array $bindings

Return Value

$this

at line 551
$this assertSessionHasErrors(string|array $keys = [], mixed $format = null)

Assert that the session has the given errors.

Parameters

string|array $keys
mixed $format

Return Value

$this

at line 576
$this assertSessionMissing(string|array $key)

Assert that the session does not have a given key.

Parameters

string|array $key

Return Value

$this

at line 597
protected Store session()

Get the current session store.

Return Value

Store

at line 607
void dump()

Dump the content from the response.

Return Value

void

at line 626
mixed __get(string $key)

Dynamically access base response parameters.

Parameters

string $key

Return Value

mixed

at line 637
mixed __isset(string $key)

Proxy isset() checks to the underlying base response.

Parameters

string $key

Return Value

mixed