trait MakesHttpRequests

Properties

protected array $serverVariables

Additional server variables for the request.

Methods

$this
withServerVariables(array $server)

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

$this
withoutMiddleware()

Disable middleware for the test.

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

Visit the given URI with a GET request.

getJson(string $uri, array $headers = [])

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

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

Visit the given URI with a POST request.

postJson(string $uri, array $data = [], array $headers = [])

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

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

Visit the given URI with a PUT request.

putJson(string $uri, array $data = [], array $headers = [])

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

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

Visit the given URI with a PATCH request.

patchJson(string $uri, array $data = [], array $headers = [])

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

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

Visit the given URI with a DELETE request.

deleteJson(string $uri, array $data = [], array $headers = [])

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

json(string $method, string $uri, array $data = [], array $headers = [])

Call the given URI with a JSON request.

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

Call the given URI and return the Response.

string
prepareUrlForRequest(string $uri)

Turn the given URI into a fully qualified URL.

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.

createTestResponse(Response $response)

Create the test response instance from the given response.

Details

at line 27
$this withServerVariables(array $server)

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

Parameters

array $server

Return Value

$this

at line 39
$this withoutMiddleware()

Disable middleware for the test.

Return Value

$this

at line 53
TestResponse get(string $uri, array $headers = [])

Visit the given URI with a GET request.

Parameters

string $uri
array $headers

Return Value

TestResponse

at line 67
TestResponse getJson(string $uri, array $headers = [])

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

Parameters

string $uri
array $headers

Return Value

TestResponse

at line 80
TestResponse post(string $uri, array $data = [], array $headers = [])

Visit the given URI with a POST request.

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 95
TestResponse postJson(string $uri, array $data = [], array $headers = [])

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

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 108
TestResponse put(string $uri, array $data = [], array $headers = [])

Visit the given URI with a PUT request.

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 123
TestResponse putJson(string $uri, array $data = [], array $headers = [])

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

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 136
TestResponse patch(string $uri, array $data = [], array $headers = [])

Visit the given URI with a PATCH request.

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 151
TestResponse patchJson(string $uri, array $data = [], array $headers = [])

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

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 164
TestResponse delete(string $uri, array $data = [], array $headers = [])

Visit the given URI with a DELETE request.

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 179
TestResponse deleteJson(string $uri, array $data = [], array $headers = [])

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

Parameters

string $uri
array $data
array $headers

Return Value

TestResponse

at line 193
TestResponse json(string $method, string $uri, array $data = [], array $headers = [])

Call the given URI with a JSON request.

Parameters

string $method
string $uri
array $data
array $headers

Return Value

TestResponse

at line 222
TestResponse call(string $method, string $uri, array $parameters = [], array $cookies = [], array $files = [], array $server = [], string $content = null)

Call the given URI and return the Response.

Parameters

string $method
string $uri
array $parameters
array $cookies
array $files
array $server
string $content

Return Value

TestResponse

at line 248
protected string prepareUrlForRequest(string $uri)

Turn the given URI into a fully qualified URL.

Parameters

string $uri

Return Value

string

at line 267
protected array transformHeadersToServerVars(array $headers)

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

Parameters

array $headers

Return Value

array

at line 282
protected string formatServerHeaderKey(string $name)

Format the header name for the server array.

Parameters

string $name

Return Value

string

at line 297
protected array extractFilesFromDataArray(array $data)

Extract the file uploads from the given data array.

Parameters

array $data

Return Value

array

at line 324
protected TestResponse createTestResponse(Response $response)

Create the test response instance from the given response.

Parameters

Response $response

Return Value

TestResponse