class ReloadRequest

Traits

Properties

protected array $defaultHeaders

Additional headers for the request.

from  MakesHttpRequests
protected array $defaultCookies

Additional cookies for the request.

from  MakesHttpRequests
protected array $unencryptedCookies

Additional cookies that will not be encrypted for the request.

from  MakesHttpRequests
protected array $serverVariables

Additional server variables for the request.

from  MakesHttpRequests
protected bool $followRedirects

Indicates whether redirects should be followed.

from  MakesHttpRequests
protected bool $encryptCookies

Indicates whether cookies should be encrypted.

from  MakesHttpRequests
protected bool $withCredentials

Indicated whether JSON requests should be performed "with credentials" (cookies).

from  MakesHttpRequests
static protected Waiter|null $waiter

The coroutine waiter for test requests.

from  MakesHttpRequests

Methods

withHeaders(array $headers)

Define additional headers to be sent with the request.

withHeader(string $name, string $value)

Add a header to be sent with the request.

withoutHeader(string $name)

Remove a header from the request.

withoutHeaders(array $headers)

Remove headers from the request.

withToken(string $token, string $type = 'Bearer')

Add an authorization token for the request.

withBasicAuth(string $username, string $password)

Add a basic authentication header to the request with the given credentials.

withoutToken()

Remove the authorization token from the request.

flushHeaders()

Flush all the configured headers.

withServerVariables(array $server)

Define a set of server variables to be sent with the requests.

withoutMiddleware(null|array|string $middleware = null)

Disable middleware for the test.

withMiddleware(null|array|string $middleware = null)

Enable the given middleware for the test.

withCookies(array $cookies)

Define additional cookies to be sent with the request.

withCookie(string $name, string $value)

Add a cookie to be sent with the request.

withUnencryptedCookies(array $cookies)

Define additional cookies that will not be encrypted before sending with the request.

withUnencryptedCookie(string $name, string $value)

Add a cookie that will not be encrypted before sending with the request.

followingRedirects()

Automatically follow any redirects returned from the response.

withCredentials()

Include cookies and authorization headers for JSON requests.

disableCookieEncryption()

Disable automatic encryption of cookie values.

from(string $url)

Set the referer header and previous URL session value in order to simulate a previous request.

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

Set the referer header and previous URL session value from a given route in order to simulate a previous request.

withPrecognition()

Set the Precognition header to "true".

get(Stringable|string $uri, array $headers = [])

Visit the given URI with a GET request.

getJson(Stringable|string $uri, array $headers = [], int $options = 0)

Visit the given URI with a GET request, expecting a JSON response.

post(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a POST request.

postJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a POST request, expecting a JSON response.

put(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PUT request.

putJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a PUT request, expecting a JSON response.

patch(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PATCH request.

patchJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a PATCH request, expecting a JSON response.

delete(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a DELETE request.

deleteJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a DELETE request, expecting a JSON response.

options(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with an OPTIONS request.

optionsJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with an OPTIONS request, expecting a JSON response.

head(Stringable|string $uri, array $headers = [])

Visit the given URI with a HEAD request.

query(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a QUERY request.

queryJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a QUERY request, expecting a JSON response.

json(string $method, Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Call the given URI with a JSON request.

call(string $method, Stringable|string $uri, array $parameters = [], array $cookies = [], array $files = [], array $server = [], string|null $content = null)

Call the given URI and return the Response.

string
prepareUrlForRequest(Stringable|string $uri)

Turn the given URI into a fully-qualified URL.

void
syncRequestContextToParent(Request $request)

Sync durable request Context state to the test coroutine.

array
sessionContextSnapshot(Request $request)

Get a snapshot of durable session Context state for the completed request.

array
sessionContextKeys()

Get durable session Context keys.

array
sessionStoreContextKeys(Store $session)

Get the Context keys for the given session store.

array
authenticationContextKeys()

Get durable authentication Context keys.

array
transformHeadersToServerVars(array $headers)

Transform headers array to array of $SERVER vars with HTTP* format.

string
formatServerHeaderKey(string $name)

Format the header name for the server array.

array
extractFilesFromDataArray(array $data)

Extract the file uploads from the given data array.

array
prepareCookiesForRequest()

If enabled, encrypt cookie values for request.

array
prepareCookiesForJsonRequest()

Prepare cookies for JSON requests.

followRedirects(mixed $response)

Follow a redirect chain until a non-redirect is received.

createTestRequest(Request $symfonyRequest)

Create the request instance used for testing from the given Symfony request.

createTestResponse(mixed $response, Request|null $request = null)

Create the test response instance from the given response.

void
dispatchRequestLifecycleEvent(string $eventClass, Request $request, Response|null $response = null)

Dispatch a request lifecycle event if enabled.

getWaiter()

Get the coroutine waiter for test requests.

__construct(string $url, string $component, string $version, string|null $only = null, string|null $except = null, Application|null $app = null)

Create a new Inertia reload request instance.

__invoke()

Execute the reload request with appropriate Inertia headers.

Details

in MakesHttpRequests at line 76
MakesHttpRequests withHeaders(array $headers)

Define additional headers to be sent with the request.

Parameters

array $headers

Return Value

MakesHttpRequests

in MakesHttpRequests at line 86
MakesHttpRequests withHeader(string $name, string $value)

Add a header to be sent with the request.

Parameters

string $name
string $value

Return Value

MakesHttpRequests

in MakesHttpRequests at line 96
MakesHttpRequests withoutHeader(string $name)

Remove a header from the request.

Parameters

string $name

Return Value

MakesHttpRequests

in MakesHttpRequests at line 106
MakesHttpRequests withoutHeaders(array $headers)

Remove headers from the request.

Parameters

array $headers

Return Value

MakesHttpRequests

in MakesHttpRequests at line 118
MakesHttpRequests withToken(string $token, string $type = 'Bearer')

Add an authorization token for the request.

Parameters

string $token
string $type

Return Value

MakesHttpRequests

in MakesHttpRequests at line 126
MakesHttpRequests withBasicAuth(string $username, string $password)

Add a basic authentication header to the request with the given credentials.

Parameters

string $username
string $password

Return Value

MakesHttpRequests

in MakesHttpRequests at line 134
MakesHttpRequests withoutToken()

Remove the authorization token from the request.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 142
MakesHttpRequests flushHeaders()

Flush all the configured headers.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 152
MakesHttpRequests withServerVariables(array $server)

Define a set of server variables to be sent with the requests.

Parameters

array $server

Return Value

MakesHttpRequests

in MakesHttpRequests at line 164
MakesHttpRequests withoutMiddleware(null|array|string $middleware = null)

Disable middleware for the test.

Parameters

null|array|string $middleware

Return Value

MakesHttpRequests

in MakesHttpRequests at line 184
MakesHttpRequests withMiddleware(null|array|string $middleware = null)

Enable the given middleware for the test.

Parameters

null|array|string $middleware

Return Value

MakesHttpRequests

in MakesHttpRequests at line 202
MakesHttpRequests withCookies(array $cookies)

Define additional cookies to be sent with the request.

Parameters

array $cookies

Return Value

MakesHttpRequests

in MakesHttpRequests at line 212
MakesHttpRequests withCookie(string $name, string $value)

Add a cookie to be sent with the request.

Parameters

string $name
string $value

Return Value

MakesHttpRequests

in MakesHttpRequests at line 222
MakesHttpRequests withUnencryptedCookies(array $cookies)

Define additional cookies that will not be encrypted before sending with the request.

Parameters

array $cookies

Return Value

MakesHttpRequests

in MakesHttpRequests at line 232
MakesHttpRequests withUnencryptedCookie(string $name, string $value)

Add a cookie that will not be encrypted before sending with the request.

Parameters

string $name
string $value

Return Value

MakesHttpRequests

in MakesHttpRequests at line 242
MakesHttpRequests followingRedirects()

Automatically follow any redirects returned from the response.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 252
MakesHttpRequests withCredentials()

Include cookies and authorization headers for JSON requests.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 262
MakesHttpRequests disableCookieEncryption()

Disable automatic encryption of cookie values.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 272
MakesHttpRequests from(string $url)

Set the referer header and previous URL session value in order to simulate a previous request.

Parameters

string $url

Return Value

MakesHttpRequests

in MakesHttpRequests at line 282
MakesHttpRequests fromRoute(BackedEnum|string $name, mixed $parameters = [])

Set the referer header and previous URL session value from a given route in order to simulate a previous request.

Parameters

BackedEnum|string $name
mixed $parameters

Return Value

MakesHttpRequests

in MakesHttpRequests at line 290
MakesHttpRequests withPrecognition()

Set the Precognition header to "true".

Return Value

MakesHttpRequests

in MakesHttpRequests at line 298
TestResponse get(Stringable|string $uri, array $headers = [])

Visit the given URI with a GET request.

Parameters

Stringable|string $uri
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 309
TestResponse getJson(Stringable|string $uri, array $headers = [], int $options = 0)

Visit the given URI with a GET request, expecting a JSON response.

Parameters

Stringable|string $uri
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 317
TestResponse post(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a POST request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 328
TestResponse postJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a POST request, expecting a JSON response.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 336
TestResponse put(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PUT request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 347
TestResponse putJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a PUT request, expecting a JSON response.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 355
TestResponse patch(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PATCH request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 366
TestResponse patchJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a PATCH request, expecting a JSON response.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 374
TestResponse delete(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a DELETE request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 385
TestResponse deleteJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a DELETE request, expecting a JSON response.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 393
TestResponse options(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with an OPTIONS request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 404
TestResponse optionsJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with an OPTIONS request, expecting a JSON response.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 412
TestResponse head(Stringable|string $uri, array $headers = [])

Visit the given URI with a HEAD request.

Parameters

Stringable|string $uri
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 423
TestResponse query(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a QUERY request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 434
TestResponse queryJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a QUERY request, expecting a JSON response.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 446
TestResponse json(string $method, Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Call the given URI with a JSON request.

Parameters

string $method
Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 477
TestResponse call(string $method, Stringable|string $uri, array $parameters = [], array $cookies = [], array $files = [], array $server = [], string|null $content = null)

Call the given URI and return the Response.

Each test request runs in a fresh coroutine via the Waiter to ensure coroutine-local Context isolation. RequestContext is seeded because tests bypass the HttpServer\Server adapter which normally does this in onRequest().

Parameters

string $method
Stringable|string $uri
array $parameters
array $cookies
array $files
array $server
string|null $content

Return Value

TestResponse

in MakesHttpRequests at line 555
protected string prepareUrlForRequest(Stringable|string $uri)

Turn the given URI into a fully-qualified URL.

Parameters

Stringable|string $uri

Return Value

string

in MakesHttpRequests at line 569
protected void syncRequestContextToParent(Request $request)

Sync durable request Context state to the test coroutine.

Parameters

Request $request

Return Value

void

in MakesHttpRequests at line 586
protected array sessionContextSnapshot(Request $request)

Get a snapshot of durable session Context state for the completed request.

Parameters

Request $request

Return Value

array

in MakesHttpRequests at line 609
protected array sessionContextKeys()

Get durable session Context keys.

Return Value

array

in MakesHttpRequests at line 628
protected array sessionStoreContextKeys(Store $session)

Get the Context keys for the given session store.

Parameters

Store $session

Return Value

array

in MakesHttpRequests at line 644
protected array authenticationContextKeys()

Get durable authentication Context keys.

Return Value

array

in MakesHttpRequests at line 662
protected array transformHeadersToServerVars(array $headers)

Transform headers array to array of $SERVER vars with HTTP* format.

Parameters

array $headers

Return Value

array

in MakesHttpRequests at line 674
protected string formatServerHeaderKey(string $name)

Format the header name for the server array.

Parameters

string $name

Return Value

string

in MakesHttpRequests at line 686
protected array extractFilesFromDataArray(array $data)

Extract the file uploads from the given data array.

Parameters

array $data

Return Value

array

in MakesHttpRequests at line 710
protected array prepareCookiesForRequest()

If enabled, encrypt cookie values for request.

Return Value

array

in MakesHttpRequests at line 725
protected array prepareCookiesForJsonRequest()

Prepare cookies for JSON requests.

Return Value

array

in MakesHttpRequests at line 734
protected TestResponse followRedirects(mixed $response)

Follow a redirect chain until a non-redirect is received.

Parameters

mixed $response

Return Value

TestResponse

in MakesHttpRequests at line 748
protected Request createTestRequest(Request $symfonyRequest)

Create the request instance used for testing from the given Symfony request.

Parameters

Request $symfonyRequest

Return Value

Request

in MakesHttpRequests at line 757
protected TestResponse createTestResponse(mixed $response, Request|null $request = null)

Create the test response instance from the given response.

Parameters

mixed $response
Request|null $request

Return Value

TestResponse

in MakesHttpRequests at line 774
protected void dispatchRequestLifecycleEvent(string $eventClass, Request $request, Response|null $response = null)

Dispatch a request lifecycle event if enabled.

Tests bypass the HttpServer\Server adapter, so lifecycle events must be dispatched here for Telescope and other watchers to work in test contexts.

Parameters

string $eventClass
Request $request
Response|null $response

Return Value

void

in MakesHttpRequests at line 799
protected Waiter getWaiter()

Get the coroutine waiter for test requests.

Return Value

Waiter

at line 20
__construct(string $url, string $component, string $version, string|null $only = null, string|null $except = null, Application|null $app = null)

Create a new Inertia reload request instance.

Parameters

string $url
string $component
string $version
string|null $only
string|null $except
Application|null $app

at line 36
TestResponse __invoke()

Execute the reload request with appropriate Inertia headers.

Return Value

TestResponse