Documentation

MakesHttpRequests

Table of Contents

$defaultHeaders  : array<string|int, mixed>
Additional headers for the request.
$followRedirects  : bool
Indicates whether redirects should be followed.
$serverVariables  : array<string|int, mixed>
Additional server variables for the request.
call()  : TestResponse
Call the given URI and return the Response.
delete()  : TestResponse
Visit the given URI with a DELETE request.
deleteJson()  : TestResponse
Visit the given URI with a DELETE request, expecting a JSON response.
flushHeaders()  : $this
Flush all the configured headers.
followingRedirects()  : $this
Automatically follow any redirects returned from the response.
from()  : $this
Set the referer header to simulate a previous request.
get()  : TestResponse
Visit the given URI with a GET request.
getJson()  : TestResponse
Visit the given URI with a GET request, expecting a JSON response.
json()  : TestResponse
Call the given URI with a JSON request.
patch()  : TestResponse
Visit the given URI with a PATCH request.
patchJson()  : TestResponse
Visit the given URI with a PATCH request, expecting a JSON response.
post()  : TestResponse
Visit the given URI with a POST request.
postJson()  : TestResponse
Visit the given URI with a POST request, expecting a JSON response.
put()  : TestResponse
Visit the given URI with a PUT request.
putJson()  : TestResponse
Visit the given URI with a PUT request, expecting a JSON response.
withHeader()  : $this
Add a header to be sent with the request.
withHeaders()  : $this
Define additional headers to be sent with the request.
withMiddleware()  : $this
Enable the given middleware for the test.
withoutMiddleware()  : $this
Disable middleware for the test.
withServerVariables()  : $this
Define a set of server variables to be sent with the requests.
createTestResponse()  : TestResponse
Create the test response instance from the given response.
extractFilesFromDataArray()  : array<string|int, mixed>
Extract the file uploads from the given data array.
followRedirects()  : Response
Follow a redirect chain until a non-redirect is received.
formatServerHeaderKey()  : string
Format the header name for the server array.
prepareUrlForRequest()  : string
Turn the given URI into a fully qualified URL.
transformHeadersToServerVars()  : array<string|int, mixed>
Transform headers array to array of $_SERVER vars with HTTP_* format.

Properties

$defaultHeaders

Additional headers for the request.

protected array<string|int, mixed> $defaultHeaders = []

$followRedirects

Indicates whether redirects should be followed.

protected bool $followRedirects = false

$serverVariables

Additional server variables for the request.

protected array<string|int, mixed> $serverVariables = []

Methods

call()

Call the given URI and return the Response.

public call(string $method, string $uri[, array<string|int, mixed> $parameters = [] ][, array<string|int, mixed> $cookies = [] ][, array<string|int, mixed> $files = [] ][, array<string|int, mixed> $server = [] ][, string $content = null ]) : TestResponse
Parameters
$method : string
$uri : string
$parameters : array<string|int, mixed> = []
$cookies : array<string|int, mixed> = []
$files : array<string|int, mixed> = []
$server : array<string|int, mixed> = []
$content : string = null
Return values
TestResponse

delete()

Visit the given URI with a DELETE request.

public delete(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

deleteJson()

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

public deleteJson(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

flushHeaders()

Flush all the configured headers.

public flushHeaders() : $this
Return values
$this

followingRedirects()

Automatically follow any redirects returned from the response.

public followingRedirects() : $this
Return values
$this

from()

Set the referer header to simulate a previous request.

public from(string $url) : $this
Parameters
$url : string
Return values
$this

get()

Visit the given URI with a GET request.

public get(string $uri[, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$headers : array<string|int, mixed> = []
Return values
TestResponse

getJson()

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

public getJson(string $uri[, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$headers : array<string|int, mixed> = []
Return values
TestResponse

json()

Call the given URI with a JSON request.

public json(string $method, string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$method : string
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

patch()

Visit the given URI with a PATCH request.

public patch(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

patchJson()

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

public patchJson(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

post()

Visit the given URI with a POST request.

public post(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

postJson()

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

public postJson(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

put()

Visit the given URI with a PUT request.

public put(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

putJson()

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

public putJson(string $uri[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : TestResponse
Parameters
$uri : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
TestResponse

withHeader()

Add a header to be sent with the request.

public withHeader(string $name, string $value) : $this
Parameters
$name : string
$value : string
Return values
$this

withHeaders()

Define additional headers to be sent with the request.

public withHeaders(array<string|int, mixed> $headers) : $this
Parameters
$headers : array<string|int, mixed>
Return values
$this

withMiddleware()

Enable the given middleware for the test.

public withMiddleware([string|array<string|int, mixed> $middleware = null ]) : $this
Parameters
$middleware : string|array<string|int, mixed> = null
Return values
$this

withoutMiddleware()

Disable middleware for the test.

public withoutMiddleware([string|array<string|int, mixed> $middleware = null ]) : $this
Parameters
$middleware : string|array<string|int, mixed> = null
Return values
$this

withServerVariables()

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

public withServerVariables(array<string|int, mixed> $server) : $this
Parameters
$server : array<string|int, mixed>
Return values
$this

extractFilesFromDataArray()

Extract the file uploads from the given data array.

protected extractFilesFromDataArray(array<string|int, mixed> &$data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
Return values
array<string|int, mixed>

formatServerHeaderKey()

Format the header name for the server array.

protected formatServerHeaderKey(string $name) : string
Parameters
$name : string
Return values
string

prepareUrlForRequest()

Turn the given URI into a fully qualified URL.

protected prepareUrlForRequest(string $uri) : string
Parameters
$uri : string
Return values
string

transformHeadersToServerVars()

Transform headers array to array of $_SERVER vars with HTTP_* format.

protected transformHeadersToServerVars(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
$headers : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results