TestResponse
class TestResponse implements ArrayAccess mixin Response (View source)
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 | $streamedContent | The streamed content of the response. |
Methods
Assert that the response has a 201 "Created" status code.
Assert that the response has a 202 "Accepted" status code.
Assert that the response has the given status code and no content.
Assert that the response has a 301 "Moved Permanently" status code.
Assert that the response has a 304 "Not Modified" status code.
Assert that the response has a 307 "Temporary Redirect" status code.
Assert that the response has a 308 "Permanent Redirect" status code.
Assert that the response has a 400 "Bad Request" status code.
Assert that the response has a 401 "Unauthorized" status code.
Assert that the response has a 402 "Payment Required" status code.
Assert that the response has a 403 "Forbidden" status code.
Assert that the response has a 404 "Not Found" status code.
Assert that the response has a 405 "Method Not Allowed" status code.
Assert that the response has a 406 "Not Acceptable" status code.
Assert that the response has a 408 "Request Timeout" status code.
Assert that the response has a 409 "Conflict" status code.
Assert that the response has a 415 "Unsupported Media Type" status code.
Assert that the response has a 422 "Unprocessable Content" status code.
Assert that the response has a 429 "Too Many Requests" status code.
Assert that the response has a 500 "Internal Server Error" status code.
Assert that the response has a 503 "Service Unavailable" status code.
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Dump the content from the response.
Call the given Closure with this instance then return the instance.
Mix another object into the class.
Dynamically handle calls to the class.
Handle dynamic calls into macros or pass missing methods to the base response.
No description
Assert that the response has a successful status code.
Assert that the Precognition request was successful.
Assert that the response is a server error.
Assert that the response has the given status code.
Get an assertion message for a status assertion containing extra details when available.
Assert whether the response is redirecting to a given URI.
Assert whether the response is redirecting to a URI that contains the given URI.
Assert whether the response is redirecting to a given route.
Assert whether the response is redirecting to a given signed route.
Asserts that the response contains the given header and equals the optional value.
Asserts that the response does not contain the given header.
Assert that the current location header matches the given URI.
Assert that the response offers a file download.
Asserts that the response contains the given cookie and equals the optional value.
Asserts that the response contains the given cookie and equals the optional value.
Asserts that the response contains the given cookie and is expired.
Asserts that the response contains the given cookie and is not expired.
Asserts that the response does not contain the given cookie.
Get the given cookie from the response.
Assert that the given string matches the response content.
Assert that the response was streamed.
Assert that the response was not streamed.
Assert that the given string matches the streamed response content.
Assert that the given array matches the streamed JSON response content.
Assert that the given string or array of strings are contained within the response.
Assert that the given HTML string or array of HTML strings are contained within the response.
Assert that the given strings are contained in order within the response.
Assert that the given HTML strings are contained in order within the response.
Assert that the given string or array of strings are contained within the response text.
Assert that the given strings are contained in order within the response text.
Assert that the given string or array of strings are not contained within the response.
Assert that the given HTML string or array of HTML strings are not contained within the response.
Assert that the given string or array of strings are not contained within the response text.
Assert that the response is a superset of the given JSON.
Assert that the expected value and type exists at the given path in the response.
Assert that the given path in the response contains all of the expected values without looking at the order.
Assert that the response has the exact given JSON.
Assert that the response has the similar JSON as given.
Assert that the response contains the given JSON fragments.
Assert that the response contains the given JSON fragment.
Assert that the response does not contain the given JSON fragment.
Assert that the response does not contain the exact JSON fragment.
Assert that the response does not contain the given path.
Assert that the response has a given JSON structure.
Assert that the response has the exact JSON structure.
Assert that the response JSON has the expected count of items at the given key.
Assert that the response has the given JSON validation errors.
Assert that the response has the given JSON validation errors but does not have any other JSON validation errors.
Assert the response has any JSON validation errors for the given key.
Assert that the response has no JSON validation errors for the given keys.
Assert that the given key is a JSON array.
Assert that the given key is a JSON object.
Validate the decoded response JSON.
Return the decoded response JSON.
Get the JSON decoded body of the response as a collection.
Assert that the response view equals the given value.
Assert that the response view has a given piece of bound data.
Assert that the response view has a given list of bound data.
Get a piece of data from the original view.
Assert that the response view is missing a piece of bound data.
Ensure that the response has a view as its original content.
Determine if the original response is a view.
Assert that the given keys do not have validation errors.
Assert that the response has the given validation errors.
Assert that the response has the given validation errors but does not have any other validation errors.
Assert that the session has a given value.
Assert that the session has a given list of values.
Assert that the session has a given value in the flashed input array.
Assert that the session has the given errors.
Assert that the session is missing the given errors.
Assert that the session has no errors.
Assert that the session has the given errors.
Assert that the session does not have a given key.
Dump the headers from the response and end the script.
Dump the body of the response and end the script.
Dump the JSON payload from the response and end the script.
Dump the session from the response and end the script.
Dump the headers from the response.
Dump the session from the response.
Get the streamed content from the response.
Dynamically access base response parameters.
Proxy isset() checks to the underlying base response.
Determine if the given offset exists.
Get the value for a given offset.
Set the value at the given offset.
Unset the value at the given offset.
Details
$this
assertNoContent(int $status = 204)
Assert that the response has the given status code and no content.
$this
assertTemporaryRedirect()
Assert that the response has a 307 "Temporary Redirect" status code.
$this
assertPermanentRedirect()
Assert that the response has a 308 "Permanent Redirect" status code.
$this
assertUnsupportedMediaType()
Assert that the response has a 415 "Unsupported Media Type" status code.
$this
assertInternalServerError()
Assert that the response has a 500 "Internal Server Error" status code.
$this
assertServiceUnavailable()
Assert that the response has a 503 "Service Unavailable" status code.
$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
mixed
__call(string $method, array $args)
Handle dynamic calls into macros or pass missing methods to the base response.
protected string
statusMessageWithDetails(string|int $expected, string|int $actual)
Get an assertion message for a status assertion containing extra details when available.
$this
assertRedirect(string|null $uri = null)
Assert whether the response is redirecting to a given URI.
$this
assertRedirectContains(string $uri)
Assert whether the response is redirecting to a URI that contains the given URI.
$this
assertRedirectToRoute(BackedEnum|string $name, mixed $parameters = [])
Assert whether the response is redirecting to a given route.
$this
assertRedirectToSignedRoute(BackedEnum|string|null $name = null, mixed $parameters = [], bool $absolute = true)
Assert whether the response is redirecting to a given signed route.
$this
assertHeader(string $headerName, mixed $value = null)
Asserts that the response contains the given header and equals the optional value.
$this
assertHeaderMissing(string $headerName)
Asserts that the response does not contain the given header.
$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, bool $unserialize = false)
Asserts that the response contains the given cookie and equals the optional value.
$this
assertCookieExpired(string $cookieName)
Asserts that the response contains the given cookie and is expired.
$this
assertCookieNotExpired(string $cookieName)
Asserts that the response contains the given cookie and is not expired.
$this
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.
$this
assertStreamedContent(string $value)
Assert that the given string matches the streamed response content.
$this
assertStreamedJsonContent(array $value)
Assert that the given array matches the streamed JSON response content.
$this
assertSee(string|array $value, bool $escape = true)
Assert that the given string or array of strings are contained within the response.
$this
assertSeeHtml(array|string $value)
Assert that the given HTML string or array of HTML strings are contained within the response.
$this
assertSeeInOrder(array $values, bool $escape = true)
Assert that the given strings are contained in order within the response.
$this
assertSeeHtmlInOrder(array $values)
Assert that the given HTML strings are contained in order within the response.
$this
assertSeeText(string|array $value, bool $escape = true)
Assert that the given string or array of strings are contained within the response text.
$this
assertSeeTextInOrder(array $values, bool $escape = true)
Assert that the given strings are contained in order within the response text.
$this
assertDontSee(string|array $value, bool $escape = true)
Assert that the given string or array of strings are not contained within the response.
$this
assertDontSeeHtml(array|string $value)
Assert that the given HTML string or array of HTML strings are not contained within the response.
$this
assertDontSeeText(string|array $value, bool $escape = true)
Assert that the given string or array of strings are not contained within the response text.
$this
assertJson(array|callable $value, bool $strict = false)
Assert that the response is a superset of the given JSON.
$this
assertJsonPath(string $path, mixed $expect)
Assert that the expected value and type exists at the given path in the response.
$this
assertJsonPathCanonicalizing(string $path, array $expect)
Assert that the given path in the response contains all of the expected values without looking at the order.
$this
assertJsonMissing(array $data, bool $exact = false)
Assert that the response does not contain the given JSON fragment.
$this
assertJsonMissingExact(array $data)
Assert that the response does not contain the exact JSON fragment.
$this
assertJsonStructure(array|null $structure = null, array|null $responseData = null)
Assert that the response has a given JSON structure.
$this
assertExactJsonStructure(array|null $structure = null, array|null $responseData = null)
Assert that the response has the exact JSON structure.
$this
assertJsonCount(int $count, string|null $key = null)
Assert that the response JSON has the expected count of items at the given key.
$this
assertJsonValidationErrors(string|array $errors, string $responseKey = 'errors')
Assert that the response has the given JSON validation errors.
$this
assertOnlyJsonValidationErrors(string|array $errors, string $responseKey = 'errors')
Assert that the response has the given JSON validation errors but does not have any other JSON validation errors.
$this
assertJsonValidationErrorFor(string $key, string $responseKey = 'errors')
Assert the response has any JSON validation errors for the given key.
$this
assertJsonMissingValidationErrors(string|array|null $keys = null, string $responseKey = 'errors')
Assert that the response has no JSON validation errors for the given keys.
Collection
collect(string|null $key = null)
Get the JSON decoded body of the response as a collection.
$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.
protected $this
ensureResponseHasView()
Ensure that the response has a view as its original content.
$this
assertValid(string|array|null $keys = null, string $errorBag = 'default', string $responseKey = 'errors')
Assert that the given keys do not have validation errors.
$this
assertInvalid(string|array|null $errors = null, string $errorBag = 'default', string $responseKey = 'errors')
Assert that the response has the given validation errors.
$this
assertOnlyInvalid(string|array|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.
$this
assertSessionHas(string|array $key, mixed $value = null)
Assert that the session has a given value.
$this
assertSessionHasInput(string|array $key, mixed $value = null)
Assert that the session has a given value in the flashed input array.
$this
assertSessionHasErrors(string|array $keys = [], mixed $format = null, string $errorBag = 'default')
Assert that the session has the given errors.
$this
assertSessionDoesntHaveErrors(string|array $keys = [], string|null $format = null, string $errorBag = 'default')
Assert that the session is missing the given errors.
$this
assertSessionHasErrorsIn(string $errorBag, string|array $keys = [], mixed $format = null)
Assert that the session has the given errors.