MakesHttpRequests
Properties
$defaultHeaders array
Additional headers for the request.
$defaultCookies array
Additional cookies for the request.
$unencryptedCookies array
Additional cookies will not be encrypted for the request.
$serverVariables array
Additional server variables for the request.
$followRedirects bool
Indicates whether redirects should be followed.
$encryptCookies bool
Indicates whether cookies should be encrypted.
$withCredentials bool
Indicated whether JSON requests should be performed "with credentials" (cookies).
Methods
withHeaders ( array $headers ) : $this
Define additional headers to be sent with the request.
Parameters
- $headers array
withHeader ( string $name , string $value ) : $this
Add a header to be sent with the request.
Parameters
- $name string
- $value string
withToken ( string $token , string $type ) : $this
Add an authorization token for the request.
Parameters
- $token string
- $type string
withBasicAuth ( string $username , string $password ) : $this
Add a basic authentication header to the request with the given credentials.
Parameters
- $username string
- $password string
withoutToken ( ) : $this
Remove the authorization token from the request.
flushHeaders ( ) : $this
Flush all the configured headers.
withServerVariables ( array $server ) : $this
Define a set of server variables to be sent with the requests.
Parameters
- $server array
withoutMiddleware ( $middleware ) : $this
Disable middleware for the test.
Parameters
- $middleware string|array|null
withMiddleware ( $middleware ) : $this
Enable the given middleware for the test.
Parameters
- $middleware string|array|null
withCookies ( array $cookies ) : $this
Define additional cookies to be sent with the request.
Parameters
- $cookies array
withCookie ( string $name , string $value ) : $this
Add a cookie to be sent with the request.
Parameters
- $name string
- $value string
withUnencryptedCookies ( array $cookies ) : $this
Define additional cookies will not be encrypted before sending with the request.
Parameters
- $cookies array
withUnencryptedCookie ( string $name , string $value ) : $this
Add a cookie will not be encrypted before sending with the request.
Parameters
- $name string
- $value string
followingRedirects ( ) : $this
Automatically follow any redirects returned from the response.
withCredentials ( ) : $this
Include cookies and authorization headers for JSON requests.
disableCookieEncryption ( ) : $this
Disable automatic encryption of cookie values.
from ( string $url ) : $this
Set the referer header and previous URL session value in order to simulate a previous request.
Parameters
- $url string
get ( $uri , array $headers ) : TestResponse
Visit the given URI with a GET request.
Parameters
- $uri string
- $headers array
getJson ( $uri , array $headers , $options ) : TestResponse
Visit the given URI with a GET request, expecting a JSON response.
Parameters
- $uri string
- $headers array
- $options int
post ( $uri , array $data , array $headers ) : TestResponse
Visit the given URI with a POST request.
Parameters
- $uri string
- $data array
- $headers array
postJson ( $uri , array $data , array $headers , $options ) : TestResponse
Visit the given URI with a POST request, expecting a JSON response.
Parameters
- $uri string
- $data array
- $headers array
- $options int
put ( $uri , array $data , array $headers ) : TestResponse
Visit the given URI with a PUT request.
Parameters
- $uri string
- $data array
- $headers array
putJson ( $uri , array $data , array $headers , $options ) : TestResponse
Visit the given URI with a PUT request, expecting a JSON response.
Parameters
- $uri string
- $data array
- $headers array
- $options int
patch ( $uri , array $data , array $headers ) : TestResponse
Visit the given URI with a PATCH request.
Parameters
- $uri string
- $data array
- $headers array
patchJson ( $uri , array $data , array $headers , $options ) : TestResponse
Visit the given URI with a PATCH request, expecting a JSON response.
Parameters
- $uri string
- $data array
- $headers array
- $options int
delete ( $uri , array $data , array $headers ) : TestResponse
Visit the given URI with a DELETE request.
Parameters
- $uri string
- $data array
- $headers array
deleteJson ( $uri , array $data , array $headers , $options ) : TestResponse
Visit the given URI with a DELETE request, expecting a JSON response.
Parameters
- $uri string
- $data array
- $headers array
- $options int
options ( $uri , array $data , array $headers ) : TestResponse
Visit the given URI with an OPTIONS request.
Parameters
- $uri string
- $data array
- $headers array
optionsJson ( $uri , array $data , array $headers , $options ) : TestResponse
Visit the given URI with an OPTIONS request, expecting a JSON response.
Parameters
- $uri string
- $data array
- $headers array
- $options int
head ( $uri , array $headers ) : TestResponse
Visit the given URI with a HEAD request.
Parameters
- $uri string
- $headers array
json ( $method , $uri , array $data , array $headers , $options ) : TestResponse
Call the given URI with a JSON request.
Parameters
- $method string
- $uri string
- $data array
- $headers array
- $options int
call ( $method , $uri , $parameters , $cookies , $files , $server , $content ) : TestResponse
Call the given URI and return the Response.
Parameters
- $method string
- $uri string
- $parameters array
- $cookies array
- $files array
- $server array
- $content string|null
prepareUrlForRequest ( $uri ) : string
Turn the given URI into a fully qualified URL.
Parameters
- $uri string
transformHeadersToServerVars ( array $headers ) : array
Transform headers array to array of $SERVER vars with HTTP* format.
Parameters
- $headers array
formatServerHeaderKey ( $name ) : string
Format the header name for the server array.
Parameters
- $name string
extractFilesFromDataArray ( $data ) : array
Extract the file uploads from the given data array.
Parameters
- $data array
prepareCookiesForRequest ( ) : array
If enabled, encrypt cookie values for request.
prepareCookiesForJsonRequest ( ) : array
If enabled, add cookies for JSON requests.
followRedirects ( $response ) : Response |TestResponse
Follow a redirect chain until a non-redirect is received.
Parameters
- $response Response
createTestResponse ( $response , $request ) : TestResponse
Create the test response instance from the given response.