TestResponse
in package
Uses
Macroable
Tags
Table of Contents
- $baseResponse : Response
- The response to delegate to.
- $macros : array<string|int, mixed>
- The registered string macros.
- __call() : mixed
- Handle dynamic calls into macros or pass missing methods to the base response.
- __callStatic() : mixed
- Dynamically handle calls to the class.
- __construct() : void
- Create a new test response instance.
- __get() : mixed
- Dynamically access base response parameters.
- __isset() : mixed
- Proxy isset() checks to the underlying base response.
- assertCookie() : $this
- Asserts that the response contains the given cookie and equals the optional value.
- assertCookieExpired() : $this
- Asserts that the response contains the given cookie and is expired.
- assertCookieMissing() : $this
- Asserts that the response does not contains the given cookie.
- assertDontSee() : $this
- Assert that the given string is not contained within the response.
- assertDontSeeText() : $this
- Assert that the given string is not contained within the response text.
- assertExactJson() : $this
- Assert that the response has the exact given JSON.
- assertHeader() : $this
- Asserts that the response contains the given header and equals the optional value.
- assertHeaderMissing() : $this
- Asserts that the response does not contains the given header.
- assertJson() : $this
- Assert that the response is a superset of the given JSON.
- assertJsonCount() : $this
- Assert that the response JSON has the expected count of items at the given key.
- assertJsonFragment() : $this
- Assert that the response contains the given JSON fragment.
- assertJsonMissing() : $this
- Assert that the response does not contain the given JSON fragment.
- assertJsonMissingExact() : $this
- Assert that the response does not contain the exact JSON fragment.
- assertJsonStructure() : $this
- Assert that the response has a given JSON structure.
- assertJsonValidationErrors() : $this
- Assert that the response has the given JSON validation errors for the given keys.
- assertPlainCookie() : $this
- Asserts that the response contains the given cookie and equals the optional value.
- assertRedirect() : $this
- Assert whether the response is redirecting to a given URI.
- assertSee() : $this
- Assert that the given string is contained within the response.
- assertSeeText() : $this
- Assert that the given string is contained within the response text.
- assertSessionHas() : $this
- Assert that the session has a given value.
- assertSessionHasAll() : $this
- Assert that the session has a given list of values.
- assertSessionHasErrors() : $this
- Assert that the session has the given errors.
- assertSessionHasErrorsIn() : $this
- Assert that the session has the given errors.
- assertSessionMissing() : $this
- Assert that the session does not have a given key.
- assertStatus() : $this
- Assert that the response has the given status code.
- assertSuccessful() : $this
- Assert that the response has a successful status code.
- assertViewHas() : $this
- Assert that the response view has a given piece of bound data.
- assertViewHasAll() : $this
- Assert that the response view has a given list of bound data.
- assertViewIs() : $this
- Assert that the response view equals the given value.
- assertViewMissing() : $this
- Assert that the response view is missing a piece of bound data.
- decodeResponseJson() : array<string|int, mixed>
- Validate and return the decoded response JSON.
- dump() : void
- Dump the content from the response.
- fromBaseResponse() : static
- Create a new TestResponse from another response.
- hasMacro() : bool
- Checks if macro is registered.
- json() : array<string|int, mixed>
- Validate and return the decoded response JSON.
- macro() : void
- Register a custom macro.
- mixin() : void
- Mix another object into the class.
- assertJsonMessage() : string
- Get the assertion message for assertJson.
- ensureResponseHasView() : $this
- Ensure that the response has a view as its original content.
- getCookie() : Cookie|null
- Get the given cookie from the response.
- session() : Store
- Get the current session store.
Properties
$baseResponse
The response to delegate to.
public
Response
$baseResponse
$macros
The registered string macros.
protected
static array<string|int, mixed>
$macros
= []
Methods
__call()
Handle dynamic calls into macros or pass missing methods to the base response.
public
__call(string $method, array<string|int, mixed> $args) : mixed
Parameters
- $method : string
- $args : array<string|int, mixed>
Return values
mixed —__callStatic()
Dynamically handle calls to the class.
public
static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
Return values
mixed —__construct()
Create a new test response instance.
public
__construct(Response $response) : void
Parameters
- $response : Response
Return values
void —__get()
Dynamically access base response parameters.
public
__get(string $key) : mixed
Parameters
- $key : string
Return values
mixed —__isset()
Proxy isset() checks to the underlying base response.
public
__isset(string $key) : mixed
Parameters
- $key : string
Return values
mixed —assertCookie()
Asserts that the response contains the given cookie and equals the optional value.
public
assertCookie(string $cookieName[, mixed $value = null ][, bool $encrypted = true ][, bool $unserialize = false ]) : $this
Parameters
- $cookieName : string
- $value : mixed = null
- $encrypted : bool = true
- $unserialize : bool = false
Return values
$this —assertCookieExpired()
Asserts that the response contains the given cookie and is expired.
public
assertCookieExpired(string $cookieName) : $this
Parameters
- $cookieName : string
Return values
$this —assertCookieMissing()
Asserts that the response does not contains the given cookie.
public
assertCookieMissing(string $cookieName) : $this
Parameters
- $cookieName : string
Return values
$this —assertDontSee()
Assert that the given string is not contained within the response.
public
assertDontSee(string $value) : $this
Parameters
- $value : string
Return values
$this —assertDontSeeText()
Assert that the given string is not contained within the response text.
public
assertDontSeeText(string $value) : $this
Parameters
- $value : string
Return values
$this —assertExactJson()
Assert that the response has the exact given JSON.
public
assertExactJson(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$this —assertHeader()
Asserts that the response contains the given header and equals the optional value.
public
assertHeader(string $headerName[, mixed $value = null ]) : $this
Parameters
- $headerName : string
- $value : mixed = null
Return values
$this —assertHeaderMissing()
Asserts that the response does not contains the given header.
public
assertHeaderMissing(string $headerName) : $this
Parameters
- $headerName : string
Return values
$this —assertJson()
Assert that the response is a superset of the given JSON.
public
assertJson(array<string|int, mixed> $data[, bool $strict = false ]) : $this
Parameters
- $data : array<string|int, mixed>
- $strict : bool = false
Return values
$this —assertJsonCount()
Assert that the response JSON has the expected count of items at the given key.
public
assertJsonCount(int $count[, string|null $key = null ]) : $this
Parameters
- $count : int
- $key : string|null = null
Return values
$this —assertJsonFragment()
Assert that the response contains the given JSON fragment.
public
assertJsonFragment(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$this —assertJsonMissing()
Assert that the response does not contain the given JSON fragment.
public
assertJsonMissing(array<string|int, mixed> $data[, bool $exact = false ]) : $this
Parameters
- $data : array<string|int, mixed>
- $exact : bool = false
Return values
$this —assertJsonMissingExact()
Assert that the response does not contain the exact JSON fragment.
public
assertJsonMissingExact(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$this —assertJsonStructure()
Assert that the response has a given JSON structure.
public
assertJsonStructure([array<string|int, mixed>|null $structure = null ][, array<string|int, mixed>|null $responseData = null ]) : $this
Parameters
- $structure : array<string|int, mixed>|null = null
- $responseData : array<string|int, mixed>|null = null
Return values
$this —assertJsonValidationErrors()
Assert that the response has the given JSON validation errors for the given keys.
public
assertJsonValidationErrors(string|array<string|int, mixed> $keys) : $this
Parameters
- $keys : string|array<string|int, mixed>
Return values
$this —assertPlainCookie()
Asserts that the response contains the given cookie and equals the optional value.
public
assertPlainCookie(string $cookieName[, mixed $value = null ][, bool $unserialize = false ]) : $this
Parameters
- $cookieName : string
- $value : mixed = null
- $unserialize : bool = false
Return values
$this —assertRedirect()
Assert whether the response is redirecting to a given URI.
public
assertRedirect([string $uri = null ]) : $this
Parameters
- $uri : string = null
Return values
$this —assertSee()
Assert that the given string is contained within the response.
public
assertSee(string $value) : $this
Parameters
- $value : string
Return values
$this —assertSeeText()
Assert that the given string is contained within the response text.
public
assertSeeText(string $value) : $this
Parameters
- $value : string
Return values
$this —assertSessionHas()
Assert that the session has a given value.
public
assertSessionHas(string|array<string|int, mixed> $key[, mixed $value = null ]) : $this
Parameters
- $key : string|array<string|int, mixed>
- $value : mixed = null
Return values
$this —assertSessionHasAll()
Assert that the session has a given list of values.
public
assertSessionHasAll(array<string|int, mixed> $bindings) : $this
Parameters
- $bindings : array<string|int, mixed>
Return values
$this —assertSessionHasErrors()
Assert that the session has the given errors.
public
assertSessionHasErrors([string|array<string|int, mixed> $keys = [] ][, mixed $format = null ][, string $errorBag = 'default' ]) : $this
Parameters
- $keys : string|array<string|int, mixed> = []
- $format : mixed = null
- $errorBag : string = 'default'
Return values
$this —assertSessionHasErrorsIn()
Assert that the session has the given errors.
public
assertSessionHasErrorsIn(string $errorBag[, string|array<string|int, mixed> $keys = [] ][, mixed $format = null ]) : $this
Parameters
- $errorBag : string
- $keys : string|array<string|int, mixed> = []
- $format : mixed = null
Return values
$this —assertSessionMissing()
Assert that the session does not have a given key.
public
assertSessionMissing(string|array<string|int, mixed> $key) : $this
Parameters
- $key : string|array<string|int, mixed>
Return values
$this —assertStatus()
Assert that the response has the given status code.
public
assertStatus(int $status) : $this
Parameters
- $status : int
Return values
$this —assertSuccessful()
Assert that the response has a successful status code.
public
assertSuccessful() : $this
Return values
$this —assertViewHas()
Assert that the response view has a given piece of bound data.
public
assertViewHas(string|array<string|int, mixed> $key[, mixed $value = null ]) : $this
Parameters
- $key : string|array<string|int, mixed>
- $value : mixed = null
Return values
$this —assertViewHasAll()
Assert that the response view has a given list of bound data.
public
assertViewHasAll(array<string|int, mixed> $bindings) : $this
Parameters
- $bindings : array<string|int, mixed>
Return values
$this —assertViewIs()
Assert that the response view equals the given value.
public
assertViewIs(string $value) : $this
Parameters
- $value : string
Return values
$this —assertViewMissing()
Assert that the response view is missing a piece of bound data.
public
assertViewMissing(string $key) : $this
Parameters
- $key : string
Return values
$this —decodeResponseJson()
Validate and return the decoded response JSON.
public
decodeResponseJson() : array<string|int, mixed>
Return values
array<string|int, mixed> —dump()
Dump the content from the response.
public
dump() : void
Return values
void —fromBaseResponse()
Create a new TestResponse from another response.
public
static fromBaseResponse(Response $response) : static
Parameters
- $response : Response
Return values
static —hasMacro()
Checks if macro is registered.
public
static hasMacro(string $name) : bool
Parameters
- $name : string
Return values
bool —json()
Validate and return the decoded response JSON.
public
json() : array<string|int, mixed>
Return values
array<string|int, mixed> —macro()
Register a custom macro.
public
static macro(string $name, object|callable $macro) : void
Parameters
- $name : string
- $macro : object|callable
Return values
void —mixin()
Mix another object into the class.
public
static mixin(object $mixin) : void
Parameters
- $mixin : object
Return values
void —assertJsonMessage()
Get the assertion message for assertJson.
protected
assertJsonMessage(array<string|int, mixed> $data) : string
Parameters
- $data : array<string|int, mixed>
Return values
string —ensureResponseHasView()
Ensure that the response has a view as its original content.
protected
ensureResponseHasView() : $this
Return values
$this —getCookie()
Get the given cookie from the response.
protected
getCookie(string $cookieName) : Cookie|null
Parameters
- $cookieName : string
Return values
Cookie|null —session()
Get the current session store.
protected
session() : Store