class Illuminate / Testing / TestResponse
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

TestResponse

Implements

Uses

Properties

public

$baseRequest Request |null

The original request.

Default: null
public

$baseResponse Response

The response to delegate to.

Default: null
public

$exceptions Illuminate\...\Collection

The collection of logged exceptions for the request.

Default: null
protected

$streamedContent string

The streamed content of the response.

Default: null

Methods

public

__construct ( $response , $request ) : void

Create a new test response instance.

Parameters

public static

fromBaseResponse ( $response , $request ) : static

Create a new TestResponse from another response.

Parameters

public

assertSuccessful ( ) : $this

Assert that the response has a successful status code.

public

assertServerError ( ) : $this

Assert that the response is a server error.

public

assertStatus ( $status ) : $this

Assert that the response has the given status code.

Parameters

  • $status int
protected

statusMessageWithDetails ( $expected , $actual ) : string

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

Parameters

  • $expected string|int
  • $actual string|int
public

assertRedirect ( $uri ) : $this

Assert whether the response is redirecting to a given URI.

Parameters

  • $uri string|null
public

assertRedirectContains ( $uri ) : $this

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

Parameters

  • $uri string
public

assertRedirectToRoute ( $name , $parameters ) : $this

Assert whether the response is redirecting to a given route.

Parameters

  • $name string
  • $parameters mixed
public

assertRedirectToSignedRoute ( $name , $parameters ) : $this

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

Parameters

  • $name string|null
  • $parameters mixed
public

assertHeader ( $headerName , $value ) : $this

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

Parameters

  • $headerName string
  • $value mixed
public

assertHeaderMissing ( $headerName ) : $this

Asserts that the response does not contain the given header.

Parameters

  • $headerName string
public

assertLocation ( $uri ) : $this

Assert that the current location header matches the given URI.

Parameters

  • $uri string
public

assertDownload ( $filename ) : $this

Assert that the response offers a file download.

Parameters

  • $filename string|null
public

assertPlainCookie ( $cookieName , $value ) : $this

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

Parameters

  • $cookieName string
  • $value mixed
public

assertCookie ( $cookieName , $value , $encrypted , $unserialize ) : $this

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

Parameters

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

assertCookieExpired ( $cookieName ) : $this

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

Parameters

  • $cookieName string
public

assertCookieNotExpired ( $cookieName ) : $this

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

Parameters

  • $cookieName string
public

assertCookieMissing ( $cookieName ) : $this

Asserts that the response does not contain the given cookie.

Parameters

  • $cookieName string
public

getCookie ( $cookieName , $decrypt , $unserialize ) : Symfony\...\Cookie|null

Get the given cookie from the response.

Parameters

  • $cookieName string
  • $decrypt bool
  • $unserialize bool
public

assertContent ( $value ) : $this

Assert that the given string matches the response content.

Parameters

  • $value string
public

assertStreamedContent ( $value ) : $this

Assert that the given string matches the streamed response content.

Parameters

  • $value string
public

assertSee ( $value , $escape ) : $this

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

Parameters

  • $value string|array
  • $escape bool
public

assertSeeInOrder ( array $values , $escape ) : $this

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

Parameters

  • $values array
  • $escape bool
public

assertSeeText ( $value , $escape ) : $this

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

Parameters

  • $value string|array
  • $escape bool
public

assertSeeTextInOrder ( array $values , $escape ) : $this

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

Parameters

  • $values array
  • $escape bool
public

assertDontSee ( $value , $escape ) : $this

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

Parameters

  • $value string|array
  • $escape bool
public

assertDontSeeText ( $value , $escape ) : $this

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

Parameters

  • $value string|array
  • $escape bool
public

assertJson ( $value , $strict ) : $this

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

Parameters

  • $value array|callable
  • $strict bool
public

assertJsonPath ( $path , $expect ) : $this

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

Parameters

  • $path string
  • $expect mixed
public

assertExactJson ( array $data ) : $this

Assert that the response has the exact given JSON.

Parameters

  • $data array
public

assertSimilarJson ( array $data ) : $this

Assert that the response has the similar JSON as given.

Parameters

  • $data array
public

assertJsonFragment ( array $data ) : $this

Assert that the response contains the given JSON fragment.

Parameters

  • $data array
public

assertJsonMissing ( array $data , $exact ) : $this

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

Parameters

  • $data array
  • $exact bool
public

assertJsonMissingExact ( array $data ) : $this

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

Parameters

  • $data array
public

assertJsonMissingPath ( string $path ) : $this

Assert that the response does not contain the given path.

Parameters

  • $path string
public

assertJsonStructure ( array $structure , $responseData ) : $this

Assert that the response has a given JSON structure.

Parameters

  • $structure array|null
  • $responseData array|null
public

assertJsonCount ( int $count , $key ) : $this

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

Parameters

  • $count int
  • $key string|null
public

assertJsonValidationErrors ( $errors , $responseKey ) : $this

Assert that the response has the given JSON validation errors.

Parameters

  • $errors string|array
  • $responseKey string
public

assertJsonValidationErrorFor ( $key , $responseKey ) : $this

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

Parameters

  • $key string
  • $responseKey string
public

assertJsonMissingValidationErrors ( $keys , $responseKey ) : $this

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

Parameters

  • $keys string|array|null
  • $responseKey string
public

assertJsonIsArray ( $key ) : $this

Assert that the given key is a JSON array.

Parameters

  • $key string|null
public

assertJsonIsObject ( $key ) : $this

Assert that the given key is a JSON object.

Parameters

  • $key string|null
public

decodeResponseJson ( ) : AssertableJsonString

Validate and return the decoded response JSON.

public

json ( $key ) : mixed

Validate and return the decoded response JSON.

Parameters

  • $key string|null
public

collect ( $key ) : Illuminate\...\Collection

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

Parameters

  • $key string|null
public

assertViewIs ( $value ) : $this

Assert that the response view equals the given value.

Parameters

  • $value string
public

assertViewHas ( $key , $value ) : $this

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

Parameters

  • $key string|array
  • $value mixed
public

assertViewHasAll ( array $bindings ) : $this

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

Parameters

  • $bindings array
public

viewData ( $key ) : mixed

Get a piece of data from the original view.

Parameters

  • $key string
public

assertViewMissing ( $key ) : $this

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

Parameters

  • $key string
protected

ensureResponseHasView ( ) : $this

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

protected

responseHasView ( ) : bool

Determine if the original response is a view.

public

assertValid ( $keys , $errorBag , $responseKey ) : $this

Assert that the given keys do not have validation errors.

Parameters

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

assertInvalid ( $errors , $errorBag , $responseKey ) : $this

Assert that the response has the given validation errors.

Parameters

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

assertSessionHas ( $key , $value ) : $this

Assert that the session has a given value.

Parameters

  • $key string|array
  • $value mixed
public

assertSessionHasAll ( array $bindings ) : $this

Assert that the session has a given list of values.

Parameters

  • $bindings array
public

assertSessionHasInput ( $key , $value ) : $this

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

Parameters

  • $key string|array
  • $value mixed
public

assertSessionHasErrors ( $keys , $format , $errorBag ) : $this

Assert that the session has the given errors.

Parameters

  • $keys string|array
  • $format mixed
  • $errorBag string
public

assertSessionDoesntHaveErrors ( $keys , $format , $errorBag ) : $this

Assert that the session is missing the given errors.

Parameters

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

assertSessionHasNoErrors ( ) : $this

Assert that the session has no errors.

public

assertSessionHasErrorsIn ( $errorBag , $keys , $format ) : $this

Assert that the session has the given errors.

Parameters

  • $errorBag string
  • $keys string|array
  • $format mixed
public

assertSessionMissing ( $key ) : $this

Assert that the session does not have a given key.

Parameters

  • $key string|array
protected

session ( ) : Store

Get the current session store.

public

ddHeaders ( ) : never

Dump the headers from the response and end the script.

public

ddSession ( $keys ) : never

Dump the session from the response and end the script.

Parameters

  • $keys string|array
public

dump ( $key ) : $this

Dump the content from the response.

Parameters

  • $key string|null
public

dumpHeaders ( ) : $this

Dump the headers from the response.

public

dumpSession ( $keys ) : $this

Dump the session from the response.

Parameters

  • $keys string|array
public

streamedContent ( ) : string

Get the streamed content from the response.

public

withExceptions ( Illuminate\...\Collection $exceptions ) : $this

Set the previous exceptions on the response.

Parameters

  • $exceptions Illuminate\...\Collection
public

transformNotSuccessfulException ( $exception ) : Throwable

This method is called when test method did not execute successfully.

Parameters

protected

appendExceptionToException ( $exceptionToAppend , $exception ) : Throwable

Append an exception to the message of another exception.

Parameters

protected

appendErrorsToException ( $errors , $exception , $json ) : Throwable

Append errors to an exception message.

Parameters

protected

appendMessageToException ( $message , $exception ) : Throwable

Append a message to an exception.

Parameters

public

__get ( $key ) : mixed

Dynamically access base response parameters.

Parameters

  • $key string
public

__isset ( $key ) : bool

Proxy isset() checks to the underlying base response.

Parameters

  • $key string
public

offsetExists ( $offset ) : bool

Determine if the given offset exists.

Parameters

  • $offset string
public

offsetGet ( $offset ) : mixed

Get the value for a given offset.

Parameters

  • $offset string
public

offsetSet ( $offset , $value ) : void

Set the value at the given offset.

Parameters

  • $offset string
  • $value mixed
public

offsetUnset ( $offset ) : void

Unset the value at the given offset.

Parameters

  • $offset string
public

__call ( $method , $args ) : mixed

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

Parameters

  • $method string
  • $args array