class TestResponse implements ArrayAccess mixin TResponse mixin Response

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
Request|null $baseRequest

The original request.

TResponse $baseResponse

The response to delegate to.

Collection $exceptions

The collection of logged exceptions for the request.

protected string|null $streamedContent

The streamed content of the response.

protected AssertableJsonString|null $decodedResponseJson

The decoded response JSON.

Methods

assertOk()

Assert that the response has a 200 "OK" status code.

assertCreated()

Assert that the response has a 201 "Created" status code.

assertAccepted()

Assert that the response has a 202 "Accepted" status code.

assertNoContent(int $status = 204)

Assert that the response has the given status code and no content.

assertMovedPermanently()

Assert that the response has a 301 "Moved Permanently" status code.

assertFound()

Assert that the response has a 302 "Found" status code.

assertNotModified()

Assert that the response has a 304 "Not Modified" status code.

assertTemporaryRedirect()

Assert that the response has a 307 "Temporary Redirect" status code.

assertPermanentRedirect()

Assert that the response has a 308 "Permanent Redirect" status code.

assertBadRequest()

Assert that the response has a 400 "Bad Request" status code.

assertUnauthorized()

Assert that the response has a 401 "Unauthorized" status code.

assertPaymentRequired()

Assert that the response has a 402 "Payment Required" status code.

assertForbidden()

Assert that the response has a 403 "Forbidden" status code.

assertNotFound()

Assert that the response has a 404 "Not Found" status code.

assertMethodNotAllowed()

Assert that the response has a 405 "Method Not Allowed" status code.

assertNotAcceptable()

Assert that the response has a 406 "Not Acceptable" status code.

assertRequestTimeout()

Assert that the response has a 408 "Request Timeout" status code.

assertConflict()

Assert that the response has a 409 "Conflict" status code.

assertGone()

Assert that the response has a 410 "Gone" status code.

assertUnsupportedMediaType()

Assert that the response has a 415 "Unsupported Media Type" status code.

assertUnprocessable()

Assert that the response has a 422 "Unprocessable Content" status code.

assertFailedDependency()

Assert that the response has a 424 "Failed Dependency" status code.

assertTooManyRequests()

Assert that the response has a 429 "Too Many Requests" status code.

assertInternalServerError()

Assert that the response has a 500 "Internal Server Error" status code.

assertServiceUnavailable()

Assert that the response has a 503 "Service Unavailable" status code.

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

never
dd(mixed ...$args)

Dump the given arguments and terminate execution.

from  Dumpable
dump(string|null $key = null)

Dump the content from the response.

mixed
tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

from  Tappable
static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

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.

__construct(TResponse $response, Request|null $request = null)

Create a new test response instance.

static TestResponse
fromBaseResponse(R $response, Request|null $request = null)

Create a new TestResponse from another response.

assertSuccessful()

Assert that the response has a successful status code.

assertSuccessfulPrecognition()

Assert that the Precognition request was successful.

assertClientError()

Assert that the response is a client error.

assertServerError()

Assert that the response is a server error.

assertStatus(int $status)

Assert that the response has the given status code.

string
statusMessageWithDetails(int|string $expected, int|string $actual)

Get an assertion message for a status assertion containing extra details when available.

assertRedirect(string|null $uri = null)

Assert whether the response is redirecting to a given URI.

assertRedirectContains(string $uri)

Assert whether the response is redirecting to a URI that contains the given URI.

assertRedirectBack()

Assert whether the response is redirecting back to the previous location.

assertRedirectBackWithErrors(array|string $keys = [], mixed $format = null, string $errorBag = 'default')

Assert whether the response is redirecting back to the previous location with the given errors in the session.

assertRedirectBackWithoutErrors()

Assert whether the response is redirecting back to the previous location with no errors in the session.

assertRedirectToRoute(BackedEnum|string $name, mixed $parameters = [])

Assert whether the response is redirecting to a given route.

assertRedirectToSignedRoute(BackedEnum|string|null $name = null, mixed $parameters = [], bool $absolute = true)

Assert whether the response is redirecting to a given signed route.

assertRedirectToAction(array|string $name, array $parameters = [])

Assert whether the response is redirecting to a given controller action.

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

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

assertHeaderContains(string $headerName, string $value)

Asserts that the response contains the given header and that its value contains the given string.

assertHeaderMissing(string $headerName)

Asserts that the response does not contain the given header.

assertLocation(string $uri)

Assert that the current location header matches the given URI.

assertDownload(string|null $filename = null)

Assert that the response offers a file download.

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

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

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

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

assertCookieExpired(string $cookieName)

Asserts that the response contains the given cookie and is expired.

assertCookieNotExpired(string $cookieName)

Asserts that the response contains the given cookie and is not expired.

assertCookieMissing(string $cookieName)

Asserts that the response does not contain the given cookie.

Cookie|null
getCookie(string $cookieName, bool $decrypt = true, bool $unserialize = false)

Get the given cookie from the response.

assertContent(string $value)

Assert that the given string matches the response content.

assertStreamed()

Assert that the response was streamed.

assertNotStreamed()

Assert that the response was not streamed.

assertStreamedContent(string $value)

Assert that the given string matches the streamed response content.

assertStreamedJsonContent(array $value)

Assert that the given array matches the streamed JSON response content.

assertSee(array|string $value, bool $escape = true)

Assert that the given string or array of strings are contained within the response.

assertSeeHtml(array|string $value)

Assert that the given HTML string or array of HTML strings are contained within the response.

assertSeeInOrder(array $values, bool $escape = true)

Assert that the given strings are contained in order within the response.

assertSeeHtmlInOrder(array $values)

Assert that the given HTML strings are contained in order within the response.

assertSeeText(array|string $value, bool $escape = true)

Assert that the given string or array of strings are contained within the response text.

assertSeeTextInOrder(array $values, bool $escape = true)

Assert that the given strings are contained in order within the response text.

assertDontSee(array|string $value, bool $escape = true)

Assert that the given string or array of strings are not contained within the response.

assertDontSeeHtml(array|string $value)

Assert that the given HTML string or array of HTML strings are not contained within the response.

assertDontSeeText(array|string $value, bool $escape = true)

Assert that the given string or array of strings are not contained within the response text.

assertJson(array|callable $value, bool $strict = false)

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

assertJsonPath(string $path, mixed $expect)

Assert that the expected value and type exists at the given path in the response.

assertJsonPaths(array $paths)

Assert that the expected values and types exist at the given paths in the response.

assertJsonPathsCanonicalizing(array $paths)

Assert that the given paths in the response contain all of the expected values without looking at the order.

assertJsonPathCanonicalizing(string $path, array $expect)

Assert that the given path in the response contains all of the expected values without looking at the order.

assertExactJson(array $data)

Assert that the response has the exact given JSON.

assertSimilarJson(array $data)

Assert that the response has the similar JSON as given.

assertJsonFragments(array $data)

Assert that the response contains the given JSON fragments.

assertJsonFragment(array $data)

Assert that the response contains the given JSON fragment.

assertJsonMissing(array $data, bool $exact = false)

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

assertJsonMissingExact(array $data)

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

assertJsonMissingPath(string $path)

Assert that the response does not contain the given path.

assertJsonMissingPaths(array $paths)

Assert that the response does not contain the given paths.

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

Assert that the response has a given JSON structure.

assertExactJsonStructure(array|null $structure = null, array|null $responseData = null)

Assert that the response has the exact JSON structure.

assertJsonCount(int $count, string|null $key = null)

Assert that the response JSON has the expected count of items at the given key.

assertJsonValidationErrors(array|string|null $errors, string $responseKey = 'errors')

Assert that the response has the given JSON validation errors.

assertOnlyJsonValidationErrors(array|string|null $errors, string $responseKey = 'errors')

Assert that the response has the given JSON validation errors but does not have any other JSON validation errors.

assertJsonValidationErrorFor(string $key, string $responseKey = 'errors')

Assert the response has any JSON validation errors for the given key.

assertJsonMissingValidationErrors(array|string|null $keys = null, string $responseKey = 'errors')

Assert that the response has no JSON validation errors for the given keys.

assertJsonIsArray(string|null $key = null)

Assert that the given key is a JSON array.

assertJsonIsObject(string|null $key = null)

Assert that the given key is a JSON object.

decodeResponseJson()

Validate the decoded response JSON.

mixed
json(string|null $key = null)

Return the decoded response JSON.

collect(string|null $key = null)

Get the decoded JSON body of the response as a collection.

assertViewIs(string $value)

Assert that the response view equals the given value.

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

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

assertViewHasAll(array $bindings)

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

mixed
viewData(string|null $key = null)

Get a piece of data from the original view.

assertViewMissing(string $key)

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

ensureResponseHasView()

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

bool
responseHasView()

Determine if the original response is a view.

assertValid(array|string|null $keys = null, string $errorBag = 'default', string $responseKey = 'errors')

Assert that the given keys do not have validation errors.

assertInvalid(array|string|null $errors = null, string $errorBag = 'default', string $responseKey = 'errors')

Assert that the response has the given validation errors.

assertOnlyInvalid(array|string|null $errors = null, string $errorBag = 'default', string $responseKey = 'errors')

Assert that the response has the given validation errors but does not have any other validation errors.

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

Assert that the session has a given value.

assertSessionHasAll(array $bindings)

Assert that the session has a given list of values.

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

Assert that the session has a given value in the flashed input array.

assertSessionMissingInput(array|string $key)

Assert that the session is missing a given key in the flashed input array.

assertSessionHasErrors(array|string $keys = [], mixed $format = null, string $errorBag = 'default')

Assert that the session has the given errors.

assertSessionDoesntHaveErrors(array|string $keys = [], string|null $format = null, string $errorBag = 'default')

Assert that the session is missing the given errors.

assertSessionHasNoErrors()

Assert that the session has no errors.

assertSessionHasErrorsIn(string $errorBag, array|string $keys = [], mixed $format = null)

Assert that the session has the given errors.

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

Assert that the session does not have a given key.

session()

Get the current session store.

never
ddHeaders()

Dump the headers from the response and end the script.

never
ddBody(string|null $key = null)

Dump the body of the response and end the script.

never
ddJson(string|null $key = null)

Dump the JSON payload from the response and end the script.

never
ddSession(array|string $keys = [])

Dump the session from the response and end the script.

dumpHeaders()

Dump the headers from the response.

dumpSession(array|string $keys = [])

Dump the session from the response.

string
getContent()

Get the response content.

string
streamedContent()

Get the streamed content from the response.

bool
isStreamedResponse()

Determine if the response is a streamed response.

withExceptions(Collection $exceptions)

Set the previous exceptions on the response.

static void
flushState()

Flush all static state.

mixed
__get(string $key)

Dynamically access base response parameters.

bool
__isset(string $key)

Proxy isset() checks to the underlying base response.

bool
offsetExists(mixed $offset)

Determine if the given offset exists.

mixed
offsetGet(mixed $offset)

Get the value for a given offset.

void
offsetSet(mixed $offset, mixed $value)

Set the value at the given offset.

void
offsetUnset(mixed $offset)

Unset the value at the given offset.

Details

in AssertsStatusCodes at line 14
AssertsStatusCodes assertOk()

Assert that the response has a 200 "OK" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 22
AssertsStatusCodes assertCreated()

Assert that the response has a 201 "Created" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 30
AssertsStatusCodes assertAccepted()

Assert that the response has a 202 "Accepted" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 38
AssertsStatusCodes assertNoContent(int $status = 204)

Assert that the response has the given status code and no content.

Parameters

int $status

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 50
AssertsStatusCodes assertMovedPermanently()

Assert that the response has a 301 "Moved Permanently" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 58
AssertsStatusCodes assertFound()

Assert that the response has a 302 "Found" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 66
AssertsStatusCodes assertNotModified()

Assert that the response has a 304 "Not Modified" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 74
AssertsStatusCodes assertTemporaryRedirect()

Assert that the response has a 307 "Temporary Redirect" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 82
AssertsStatusCodes assertPermanentRedirect()

Assert that the response has a 308 "Permanent Redirect" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 90
AssertsStatusCodes assertBadRequest()

Assert that the response has a 400 "Bad Request" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 98
AssertsStatusCodes assertUnauthorized()

Assert that the response has a 401 "Unauthorized" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 106
AssertsStatusCodes assertPaymentRequired()

Assert that the response has a 402 "Payment Required" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 114
AssertsStatusCodes assertForbidden()

Assert that the response has a 403 "Forbidden" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 122
AssertsStatusCodes assertNotFound()

Assert that the response has a 404 "Not Found" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 130
AssertsStatusCodes assertMethodNotAllowed()

Assert that the response has a 405 "Method Not Allowed" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 138
AssertsStatusCodes assertNotAcceptable()

Assert that the response has a 406 "Not Acceptable" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 146
AssertsStatusCodes assertRequestTimeout()

Assert that the response has a 408 "Request Timeout" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 154
AssertsStatusCodes assertConflict()

Assert that the response has a 409 "Conflict" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 162
AssertsStatusCodes assertGone()

Assert that the response has a 410 "Gone" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 170
AssertsStatusCodes assertUnsupportedMediaType()

Assert that the response has a 415 "Unsupported Media Type" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 178
AssertsStatusCodes assertUnprocessable()

Assert that the response has a 422 "Unprocessable Content" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 186
AssertsStatusCodes assertFailedDependency()

Assert that the response has a 424 "Failed Dependency" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 194
AssertsStatusCodes assertTooManyRequests()

Assert that the response has a 429 "Too Many Requests" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 202
AssertsStatusCodes assertInternalServerError()

Assert that the response has a 500 "Internal Server Error" status code.

Return Value

AssertsStatusCodes

in AssertsStatusCodes at line 210
AssertsStatusCodes assertServiceUnavailable()

Assert that the response has a 503 "Service Unavailable" status code.

Return Value

AssertsStatusCodes

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Dumpable at line 12
never dd(mixed ...$args)

Dump the given arguments and terminate execution.

Parameters

mixed ...$args

Return Value

never

at line 1650
TestResponse dump(string|null $key = null)

Dump the content from the response.

Parameters

string|null $key

Return Value

TestResponse

in Tappable at line 17
mixed tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

Parameters

callable|null $callback

Return Value

mixed

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

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

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
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 1830
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 85
__construct(TResponse $response, Request|null $request = null)

Create a new test response instance.

Parameters

TResponse $response
Request|null $request

at line 100
static TestResponse fromBaseResponse(R $response, Request|null $request = null)

Create a new TestResponse from another response.

Parameters

R $response
Request|null $request

Return Value

TestResponse

at line 108
TestResponse assertSuccessful()

Assert that the response has a successful status code.

Return Value

TestResponse

at line 121
TestResponse assertSuccessfulPrecognition()

Assert that the Precognition request was successful.

Return Value

TestResponse

at line 142
TestResponse assertClientError()

Assert that the response is a client error.

Return Value

TestResponse

at line 155
TestResponse assertServerError()

Assert that the response is a server error.

Return Value

TestResponse

at line 168
TestResponse assertStatus(int $status)

Assert that the response has the given status code.

Parameters

int $status

Return Value

TestResponse

at line 180
protected string statusMessageWithDetails(int|string $expected, int|string $actual)

Get an assertion message for a status assertion containing extra details when available.

Parameters

int|string $expected
int|string $actual

Return Value

string

at line 188
TestResponse assertRedirect(string|null $uri = null)

Assert whether the response is redirecting to a given URI.

Parameters

string|null $uri

Return Value

TestResponse

at line 205
TestResponse assertRedirectContains(string $uri)

Assert whether the response is redirecting to a URI that contains the given URI.

Parameters

string $uri

Return Value

TestResponse

at line 223
TestResponse assertRedirectBack()

Assert whether the response is redirecting back to the previous location.

Return Value

TestResponse

at line 238
TestResponse assertRedirectBackWithErrors(array|string $keys = [], mixed $format = null, string $errorBag = 'default')

Assert whether the response is redirecting back to the previous location with the given errors in the session.

Parameters

array|string $keys
mixed $format
string $errorBag

Return Value

TestResponse

at line 250
TestResponse assertRedirectBackWithoutErrors()

Assert whether the response is redirecting back to the previous location with no errors in the session.

Return Value

TestResponse

at line 262
TestResponse assertRedirectToRoute(BackedEnum|string $name, mixed $parameters = [])

Assert whether the response is redirecting to a given route.

Parameters

BackedEnum|string $name
mixed $parameters

Return Value

TestResponse

at line 279
TestResponse assertRedirectToSignedRoute(BackedEnum|string|null $name = null, mixed $parameters = [], bool $absolute = true)

Assert whether the response is redirecting to a given signed route.

Parameters

BackedEnum|string|null $name
mixed $parameters
bool $absolute

Return Value

TestResponse

at line 315
TestResponse assertRedirectToAction(array|string $name, array $parameters = [])

Assert whether the response is redirecting to a given controller action.

Parameters

array|string $name
array $parameters

Return Value

TestResponse

at line 332
TestResponse 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

TestResponse

at line 355
TestResponse assertHeaderContains(string $headerName, string $value)

Asserts that the response contains the given header and that its value contains the given string.

Parameters

string $headerName
string $value

Return Value

TestResponse

at line 375
TestResponse assertHeaderMissing(string $headerName)

Asserts that the response does not contain the given header.

Parameters

string $headerName

Return Value

TestResponse

at line 388
TestResponse assertLocation(string $uri)

Assert that the current location header matches the given URI.

Parameters

string $uri

Return Value

TestResponse

at line 401
TestResponse assertDownload(string|null $filename = null)

Assert that the response offers a file download.

Parameters

string|null $filename

Return Value

TestResponse

at line 446
TestResponse 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

TestResponse

at line 456
TestResponse assertCookie(string $cookieName, mixed $value = null, bool $encrypted = true, bool $unserialize = false)

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

Parameters

string $cookieName
mixed $value
bool $encrypted
bool $unserialize

Return Value

TestResponse

at line 481
TestResponse assertCookieExpired(string $cookieName)

Asserts that the response contains the given cookie and is expired.

Parameters

string $cookieName

Return Value

TestResponse

at line 501
TestResponse assertCookieNotExpired(string $cookieName)

Asserts that the response contains the given cookie and is not expired.

Parameters

string $cookieName

Return Value

TestResponse

at line 521
TestResponse assertCookieMissing(string $cookieName)

Asserts that the response does not contain the given cookie.

Parameters

string $cookieName

Return Value

TestResponse

at line 534
Cookie|null getCookie(string $cookieName, bool $decrypt = true, bool $unserialize = false)

Get the given cookie from the response.

Parameters

string $cookieName
bool $decrypt
bool $unserialize

Return Value

Cookie|null

at line 567
TestResponse assertContent(string $value)

Assert that the given string matches the response content.

Parameters

string $value

Return Value

TestResponse

at line 577
TestResponse assertStreamed()

Assert that the response was streamed.

Return Value

TestResponse

at line 590
TestResponse assertNotStreamed()

Assert that the response was not streamed.

Return Value

TestResponse

at line 603
TestResponse assertStreamedContent(string $value)

Assert that the given string matches the streamed response content.

Parameters

string $value

Return Value

TestResponse

at line 615
TestResponse assertStreamedJsonContent(array $value)

Assert that the given array matches the streamed JSON response content.

Parameters

array $value

Return Value

TestResponse

Exceptions

JsonException

at line 625
TestResponse assertSee(array|string $value, bool $escape = true)

Assert that the given string or array of strings are contained within the response.

Parameters

array|string $value
bool $escape

Return Value

TestResponse

at line 643
TestResponse assertSeeHtml(array|string $value)

Assert that the given HTML string or array of HTML strings are contained within the response.

Parameters

array|string $value

Return Value

TestResponse

at line 653
TestResponse assertSeeInOrder(array $values, bool $escape = true)

Assert that the given strings are contained in order within the response.

Parameters

array $values
bool $escape

Return Value

TestResponse

at line 667
TestResponse assertSeeHtmlInOrder(array $values)

Assert that the given HTML strings are contained in order within the response.

Parameters

array $values

Return Value

TestResponse

at line 677
TestResponse assertSeeText(array|string $value, bool $escape = true)

Assert that the given string or array of strings are contained within the response text.

Parameters

array|string $value
bool $escape

Return Value

TestResponse

at line 693
TestResponse assertSeeTextInOrder(array $values, bool $escape = true)

Assert that the given strings are contained in order within the response text.

Parameters

array $values
bool $escape

Return Value

TestResponse

at line 707
TestResponse assertDontSee(array|string $value, bool $escape = true)

Assert that the given string or array of strings are not contained within the response.

Parameters

array|string $value
bool $escape

Return Value

TestResponse

at line 725
TestResponse assertDontSeeHtml(array|string $value)

Assert that the given HTML string or array of HTML strings are not contained within the response.

Parameters

array|string $value

Return Value

TestResponse

at line 735
TestResponse assertDontSeeText(array|string $value, bool $escape = true)

Assert that the given string or array of strings are not contained within the response text.

Parameters

array|string $value
bool $escape

Return Value

TestResponse

at line 749
TestResponse assertJson(array|callable $value, bool $strict = false)

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

Parameters

array|callable $value
bool $strict

Return Value

TestResponse

at line 771
TestResponse assertJsonPath(string $path, mixed $expect)

Assert that the expected value and type exists at the given path in the response.

Parameters

string $path
mixed $expect

Return Value

TestResponse

at line 783
TestResponse assertJsonPaths(array $paths)

Assert that the expected values and types exist at the given paths in the response.

Parameters

array $paths

Return Value

TestResponse

at line 797
TestResponse assertJsonPathsCanonicalizing(array $paths)

Assert that the given paths in the response contain all of the expected values without looking at the order.

Parameters

array $paths

Return Value

TestResponse

at line 809
TestResponse assertJsonPathCanonicalizing(string $path, array $expect)

Assert that the given path in the response contains all of the expected values without looking at the order.

Parameters

string $path
array $expect

Return Value

TestResponse

at line 819
TestResponse assertExactJson(array $data)

Assert that the response has the exact given JSON.

Parameters

array $data

Return Value

TestResponse

at line 829
TestResponse assertSimilarJson(array $data)

Assert that the response has the similar JSON as given.

Parameters

array $data

Return Value

TestResponse

at line 839
TestResponse assertJsonFragments(array $data)

Assert that the response contains the given JSON fragments.

Parameters

array $data

Return Value

TestResponse

at line 851
TestResponse assertJsonFragment(array $data)

Assert that the response contains the given JSON fragment.

Parameters

array $data

Return Value

TestResponse

at line 861
TestResponse assertJsonMissing(array $data, bool $exact = false)

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

Parameters

array $data
bool $exact

Return Value

TestResponse

at line 871
TestResponse assertJsonMissingExact(array $data)

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

Parameters

array $data

Return Value

TestResponse

at line 881
TestResponse assertJsonMissingPath(string $path)

Assert that the response does not contain the given path.

Parameters

string $path

Return Value

TestResponse

at line 893
TestResponse assertJsonMissingPaths(array $paths)

Assert that the response does not contain the given paths.

Parameters

array $paths

Return Value

TestResponse

at line 905
TestResponse assertJsonStructure(array|null $structure = null, array|null $responseData = null)

Assert that the response has a given JSON structure.

Parameters

array|null $structure
array|null $responseData

Return Value

TestResponse

at line 915
TestResponse assertExactJsonStructure(array|null $structure = null, array|null $responseData = null)

Assert that the response has the exact JSON structure.

Parameters

array|null $structure
array|null $responseData

Return Value

TestResponse

at line 925
TestResponse assertJsonCount(int $count, string|null $key = null)

Assert that the response JSON has the expected count of items at the given key.

Parameters

int $count
string|null $key

Return Value

TestResponse

at line 935
TestResponse assertJsonValidationErrors(array|string|null $errors, string $responseKey = 'errors')

Assert that the response has the given JSON validation errors.

Parameters

array|string|null $errors
string $responseKey

Return Value

TestResponse

at line 982
TestResponse assertOnlyJsonValidationErrors(array|string|null $errors, string $responseKey = 'errors')

Assert that the response has the given JSON validation errors but does not have any other JSON validation errors.

Parameters

array|string|null $errors
string $responseKey

Return Value

TestResponse

at line 1005
TestResponse assertJsonValidationErrorFor(string $key, string $responseKey = 'errors')

Assert the response has any JSON validation errors for the given key.

Parameters

string $key
string $responseKey

Return Value

TestResponse

at line 1026
TestResponse assertJsonMissingValidationErrors(array|string|null $keys = null, string $responseKey = 'errors')

Assert that the response has no JSON validation errors for the given keys.

Parameters

array|string|null $keys
string $responseKey

Return Value

TestResponse

at line 1064
TestResponse assertJsonIsArray(string|null $key = null)

Assert that the given key is a JSON array.

Parameters

string|null $key

Return Value

TestResponse

at line 1082
TestResponse assertJsonIsObject(string|null $key = null)

Assert that the given key is a JSON object.

Parameters

string|null $key

Return Value

TestResponse

at line 1102
AssertableJsonString decodeResponseJson()

Validate the decoded response JSON.

Return Value

AssertableJsonString

Exceptions

Throwable

at line 1127
mixed json(string|null $key = null)

Return the decoded response JSON.

Parameters

string|null $key

Return Value

mixed

at line 1135
Collection collect(string|null $key = null)

Get the decoded JSON body of the response as a collection.

Parameters

string|null $key

Return Value

Collection

at line 1143
TestResponse assertViewIs(string $value)

Assert that the response view equals the given value.

Parameters

string $value

Return Value

TestResponse

at line 1155
TestResponse assertViewHas(array|string $key, mixed $value = null)

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

Parameters

array|string $key
mixed $value

Return Value

TestResponse

at line 1196
TestResponse assertViewHasAll(array $bindings)

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

Parameters

array $bindings

Return Value

TestResponse

at line 1212
mixed viewData(string|null $key = null)

Get a piece of data from the original view.

Parameters

string|null $key

Return Value

mixed

at line 1228
TestResponse assertViewMissing(string $key)

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

Parameters

string $key

Return Value

TestResponse

at line 1240
protected TestResponse ensureResponseHasView()

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

Return Value

TestResponse

at line 1252
protected bool responseHasView()

Determine if the original response is a view.

Return Value

bool

at line 1260
TestResponse assertValid(array|string|null $keys = null, string $errorBag = 'default', string $responseKey = 'errors')

Assert that the given keys do not have validation errors.

Parameters

array|string|null $keys
string $errorBag
string $responseKey

Return Value

TestResponse

at line 1298
TestResponse assertInvalid(array|string|null $errors = null, string $errorBag = 'default', string $responseKey = 'errors')

Assert that the response has the given validation errors.

Parameters

array|string|null $errors
string $errorBag
string $responseKey

Return Value

TestResponse

at line 1347
TestResponse assertOnlyInvalid(array|string|null $errors = null, string $errorBag = 'default', string $responseKey = 'errors')

Assert that the response has the given validation errors but does not have any other validation errors.

Parameters

array|string|null $errors
string $errorBag
string $responseKey

Return Value

TestResponse

at line 1376
TestResponse assertSessionHas(array|string $key, mixed $value = null)

Assert that the session has a given value.

Parameters

array|string $key
mixed $value

Return Value

TestResponse

at line 1399
TestResponse assertSessionHasAll(array $bindings)

Assert that the session has a given list of values.

Parameters

array $bindings

Return Value

TestResponse

at line 1426
TestResponse assertSessionHasInput(array|string $key, mixed $value = null)

Assert that the session has a given value in the flashed input array.

Parameters

array|string $key
mixed $value

Return Value

TestResponse

at line 1460
TestResponse assertSessionMissingInput(array|string $key)

Assert that the session is missing a given key in the flashed input array.

Parameters

array|string $key

Return Value

TestResponse

at line 1481
TestResponse assertSessionHasErrors(array|string $keys = [], mixed $format = null, string $errorBag = 'default')

Assert that the session has the given errors.

Parameters

array|string $keys
mixed $format
string $errorBag

Return Value

TestResponse

at line 1503
TestResponse assertSessionDoesntHaveErrors(array|string $keys = [], string|null $format = null, string $errorBag = 'default')

Assert that the session is missing the given errors.

Parameters

array|string $keys
string|null $format
string $errorBag

Return Value

TestResponse

at line 1535
TestResponse assertSessionHasNoErrors()

Assert that the session has no errors.

Return Value

TestResponse

Exceptions

JsonException

at line 1565
TestResponse assertSessionHasErrorsIn(string $errorBag, array|string $keys = [], mixed $format = null)

Assert that the session has the given errors.

Parameters

string $errorBag
array|string $keys
mixed $format

Return Value

TestResponse

at line 1573
TestResponse assertSessionMissing(array|string $key, mixed $value = null)

Assert that the session does not have a given key.

Parameters

array|string $key
mixed $value

Return Value

TestResponse

at line 1600
protected Session session()

Get the current session store.

Return Value

Session

at line 1608
never ddHeaders()

Dump the headers from the response and end the script.

Return Value

never

at line 1618
never ddBody(string|null $key = null)

Dump the body of the response and end the script.

Parameters

string|null $key

Return Value

never

at line 1632
never ddJson(string|null $key = null)

Dump the JSON payload from the response and end the script.

Parameters

string|null $key

Return Value

never

at line 1640
never ddSession(array|string $keys = [])

Dump the session from the response and end the script.

Parameters

array|string $keys

Return Value

never

at line 1673
TestResponse dumpHeaders()

Dump the headers from the response.

Return Value

TestResponse

at line 1683
TestResponse dumpSession(array|string $keys = [])

Dump the session from the response.

Parameters

array|string $keys

Return Value

TestResponse

at line 1699
string getContent()

Get the response content.

Return Value

string

at line 1710
string streamedContent()

Get the streamed content from the response.

Return Value

string

at line 1748
protected bool isStreamedResponse()

Determine if the response is a streamed response.

Return Value

bool

at line 1756
TestResponse withExceptions(Collection $exceptions)

Set the previous exceptions on the response.

Parameters

Collection $exceptions

Return Value

TestResponse

at line 1766
static void flushState()

Flush all static state.

Return Value

void

at line 1774
mixed __get(string $key)

Dynamically access base response parameters.

Parameters

string $key

Return Value

mixed

at line 1782
bool __isset(string $key)

Proxy isset() checks to the underlying base response.

Parameters

string $key

Return Value

bool

at line 1790
bool offsetExists(mixed $offset)

Determine if the given offset exists.

Parameters

mixed $offset

Return Value

bool

at line 1800
mixed offsetGet(mixed $offset)

Get the value for a given offset.

Parameters

mixed $offset

Return Value

mixed

at line 1812
void offsetSet(mixed $offset, mixed $value)

Set the value at the given offset.

Parameters

mixed $offset
mixed $value

Return Value

void

Exceptions

LogicException

at line 1822
void offsetUnset(mixed $offset)

Unset the value at the given offset.

Parameters

mixed $offset

Return Value

void

Exceptions

LogicException