ReloadRequest
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
Define additional headers to be sent with the request.
Add a header to be sent with the request.
Remove a header from the request.
Remove headers from the request.
Add an authorization token for the request.
Add a basic authentication header to the request with the given credentials.
Remove the authorization token from the request.
Define a set of server variables to be sent with the requests.
Disable middleware for the test.
Enable the given middleware for the test.
Define additional cookies to be sent with the request.
Add a cookie to be sent with the request.
Define additional cookies that will not be encrypted before sending with the request.
Add a cookie that will not be encrypted before sending with the request.
Automatically follow any redirects returned from the response.
Include cookies and authorization headers for JSON requests.
Disable automatic encryption of cookie values.
Set the referer header and previous URL session value in order to simulate a previous request.
Set the referer header and previous URL session value from a given route in order to simulate a previous request.
Visit the given URI with a GET request, expecting a JSON response.
Visit the given URI with a POST request.
Visit the given URI with a POST request, expecting a JSON response.
Visit the given URI with a PUT request.
Visit the given URI with a PUT request, expecting a JSON response.
Visit the given URI with a PATCH request.
Visit the given URI with a PATCH request, expecting a JSON response.
Visit the given URI with a DELETE request.
Visit the given URI with a DELETE request, expecting a JSON response.
Visit the given URI with an OPTIONS request.
Visit the given URI with an OPTIONS request, expecting a JSON response.
Visit the given URI with a QUERY request.
Visit the given URI with a QUERY request, expecting a JSON response.
Call the given URI with a JSON request.
Call the given URI and return the Response.
Sync durable request Context state to the test coroutine.
Get a snapshot of durable session Context state for the completed request.
Transform headers array to array of $SERVER vars with HTTP* format.
Format the header name for the server array.
Extract the file uploads from the given data array.
If enabled, encrypt cookie values for request.
Follow a redirect chain until a non-redirect is received.
Create the request instance used for testing from the given Symfony request.
Create the test response instance from the given response.
Dispatch a request lifecycle event if enabled.
Create a new Inertia reload request instance.
Execute the reload request with appropriate Inertia headers.
Details
in
MakesHttpRequests at line 80
MakesHttpRequests
withHeaders(array $headers)
Define additional headers to be sent with the request.
in
MakesHttpRequests at line 92
MakesHttpRequests
withHeader(string $name, string $value)
Add a header to be sent with the request.
in
MakesHttpRequests at line 104
MakesHttpRequests
withoutHeader(string $name)
Remove a header from the request.
in
MakesHttpRequests at line 116
MakesHttpRequests
withoutHeaders(array $headers)
Remove headers from the request.
in
MakesHttpRequests at line 130
MakesHttpRequests
withToken(string $token, string $type = 'Bearer')
Add an authorization token for the request.
in
MakesHttpRequests at line 140
MakesHttpRequests
withBasicAuth(string $username, string $password)
Add a basic authentication header to the request with the given credentials.
in
MakesHttpRequests at line 150
MakesHttpRequests
withoutToken()
Remove the authorization token from the request.
in
MakesHttpRequests at line 160
MakesHttpRequests
flushHeaders()
Flush all the configured headers.
in
MakesHttpRequests at line 172
MakesHttpRequests
withServerVariables(array $server)
Define a set of server variables to be sent with the requests.
in
MakesHttpRequests at line 185
MakesHttpRequests
withoutMiddleware(null|array|string $middleware = null)
Disable middleware for the test.
in
MakesHttpRequests at line 206
MakesHttpRequests
withMiddleware(null|array|string $middleware = null)
Enable the given middleware for the test.
in
MakesHttpRequests at line 226
MakesHttpRequests
withCookies(array $cookies)
Define additional cookies to be sent with the request.
in
MakesHttpRequests at line 238
MakesHttpRequests
withCookie(string $name, string $value)
Add a cookie to be sent with the request.
in
MakesHttpRequests at line 250
MakesHttpRequests
withUnencryptedCookies(array $cookies)
Define additional cookies that will not be encrypted before sending with the request.
in
MakesHttpRequests at line 262
MakesHttpRequests
withUnencryptedCookie(string $name, string $value)
Add a cookie that will not be encrypted before sending with the request.
in
MakesHttpRequests at line 274
MakesHttpRequests
followingRedirects()
Automatically follow any redirects returned from the response.
in
MakesHttpRequests at line 286
MakesHttpRequests
withCredentials()
Include cookies and authorization headers for JSON requests.
in
MakesHttpRequests at line 298
MakesHttpRequests
disableCookieEncryption()
Disable automatic encryption of cookie values.
in
MakesHttpRequests at line 310
MakesHttpRequests
from(string $url)
Set the referer header and previous URL session value in order to simulate a previous request.
in
MakesHttpRequests at line 322
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.
in
MakesHttpRequests at line 332
MakesHttpRequests
withPrecognition()
Set the Precognition header to "true".
in
MakesHttpRequests at line 340
TestResponse
get(Stringable|string $uri, array $headers = [])
Visit the given URI with a GET request.
in
MakesHttpRequests at line 351
TestResponse
getJson(Stringable|string $uri, array $headers = [], int $options = 0)
Visit the given URI with a GET request, expecting a JSON response.
in
MakesHttpRequests at line 359
TestResponse
post(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a POST request.
in
MakesHttpRequests at line 370
TestResponse
postJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a POST request, expecting a JSON response.
in
MakesHttpRequests at line 378
TestResponse
put(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a PUT request.
in
MakesHttpRequests at line 389
TestResponse
putJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a PUT request, expecting a JSON response.
in
MakesHttpRequests at line 397
TestResponse
patch(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a PATCH request.
in
MakesHttpRequests at line 408
TestResponse
patchJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a PATCH request, expecting a JSON response.
in
MakesHttpRequests at line 416
TestResponse
delete(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a DELETE request.
in
MakesHttpRequests at line 427
TestResponse
deleteJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a DELETE request, expecting a JSON response.
in
MakesHttpRequests at line 435
TestResponse
options(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with an OPTIONS request.
in
MakesHttpRequests at line 446
TestResponse
optionsJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with an OPTIONS request, expecting a JSON response.
in
MakesHttpRequests at line 454
TestResponse
head(Stringable|string $uri, array $headers = [])
Visit the given URI with a HEAD request.
in
MakesHttpRequests at line 465
TestResponse
query(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a QUERY request.
in
MakesHttpRequests at line 476
TestResponse
queryJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a QUERY request, expecting a JSON response.
in
MakesHttpRequests at line 488
TestResponse
json(string $method, Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Call the given URI with a JSON request.
in
MakesHttpRequests at line 519
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().
in
MakesHttpRequests at line 616
protected string
prepareUrlForRequest(Stringable|string $uri)
Turn the given URI into a fully-qualified URL.
in
MakesHttpRequests at line 630
protected void
syncRequestContextToParent(Request $request)
Sync durable request Context state to the test coroutine.
in
MakesHttpRequests at line 651
protected array
sessionContextSnapshot(Request $request)
Get a snapshot of durable session Context state for the completed request.
in
MakesHttpRequests at line 674
protected array
sessionContextKeys()
Get durable session Context keys.
in
MakesHttpRequests at line 693
protected array
sessionStoreContextKeys(Store $session)
Get the Context keys for the given session store.
in
MakesHttpRequests at line 709
protected array
authenticationContextKeys()
Get durable authentication Context keys.
in
MakesHttpRequests at line 727
protected array
transformHeadersToServerVars(array $headers)
Transform headers array to array of $SERVER vars with HTTP* format.
in
MakesHttpRequests at line 739
protected string
formatServerHeaderKey(string $name)
Format the header name for the server array.
in
MakesHttpRequests at line 751
protected array
extractFilesFromDataArray(array $data)
Extract the file uploads from the given data array.
in
MakesHttpRequests at line 775
protected array
prepareCookiesForRequest()
If enabled, encrypt cookie values for request.
in
MakesHttpRequests at line 790
protected array
prepareCookiesForJsonRequest()
Prepare cookies for JSON requests.
in
MakesHttpRequests at line 799
protected TestResponse
followRedirects(mixed $response)
Follow a redirect chain until a non-redirect is received.
in
MakesHttpRequests at line 813
protected Request
createTestRequest(Request $symfonyRequest)
Create the request instance used for testing from the given Symfony request.
in
MakesHttpRequests at line 822
protected TestResponse
createTestResponse(mixed $response, Request|null $request = null)
Create the test response instance from the given response.
in
MakesHttpRequests at line 839
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.
in
MakesHttpRequests at line 864
protected Waiter
getWaiter()
Get the coroutine waiter for test requests.
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.
at line 36
TestResponse
__invoke()
Execute the reload request with appropriate Inertia headers.