TestResponse
class TestResponse mixin Response (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
Response | $baseResponse | The response to delegate to. |
Methods
Dynamically handle calls to the class.
Handle dynamic calls into macros or pass missing methods to the base response.
Assert that the response has a successful status code.
Assert that the response has the given status code.
Assert whether the response is redirecting to a given URI.
Asserts that the response contains the given header and equals the optional value.
Asserts that the response does not contains the given header.
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 does not contains the given cookie.
Get the given cookie from the response.
Assert that the given string is contained within the response.
Assert that the given string is contained within the response text.
Assert that the given string is not contained within the response.
Assert that the given string is not contained within the response text.
Assert that the response is a superset of the given JSON.
Get the assertion message for assertJson.
Assert that the response has the exact given JSON.
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 has a given 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 for the given keys.
Validate and return the decoded response JSON.
Validate and return the decoded response JSON.
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.
Assert that the response view is missing a piece of bound data.
Ensure that the response has a view as its original content.
Assert that the session has a given value.
Assert that the session has a given list of values.
Assert that the session has the given errors.
Assert that the session has the given errors.
Assert that the session does not have a given key.
Dump the content from the response.
Dynamically access base response parameters.
Proxy isset() checks to the underlying base response.
Details
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin)
Mix another object into the class.
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
assertHeaderMissing(string $headerName)
Asserts that the response does not contains the given header.
$this
assertPlainCookie(string $cookieName, mixed $value = null, bool $unserialize = false)
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
assertCookieMissing(string $cookieName)
Asserts that the response does not contains the given cookie.
protected 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, bool $strict = false)
Assert that the response is a superset of the given JSON.
protected 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, 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 $structure = null, array|null $responseData = null)
Assert that the response has a given 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 $keys)
Assert that the response has the given JSON validation errors for the given keys.
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.
protected $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, string $errorBag = 'default')
Assert that the session has the given errors.
$this
assertSessionHasErrorsIn(string $errorBag, 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.
protected Store
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.