MakesHttpRequests

trait MakesHttpRequests (View source)

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.

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

Visit the given URI with a GET request.

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

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

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

Visit the given URI with a POST request.

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

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

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

Visit the given URI with a PUT request.

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

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

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

Visit the given URI with a PATCH request.

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

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

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

Visit the given URI with a DELETE request.

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

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

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

Call the given URI with a JSON request.

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.

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.

TestResponse createTestResponse(Response $response)

Create the test response instance from the given response.

Details

$this withServerVariables(array $server)

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

Parameters

array $server

Return Value

$this

$this withoutMiddleware()

Disable middleware for the test.

Return Value

$this

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

Visit the given URI with a GET request.

Parameters

string $uri
array $headers

Return Value

TestResponse

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

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

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

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

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

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

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

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

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

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

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

protected string prepareUrlForRequest(string $uri)

Turn the given URI into a fully qualified URL.

Parameters

string $uri

Return Value

string

protected array transformHeadersToServerVars(array $headers)

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

Parameters

array $headers

Return Value

array

protected string formatServerHeaderKey(string $name)

Format the header name for the server array.

Parameters

string $name

Return Value

string

protected array extractFilesFromDataArray(array $data)

Extract the file uploads from the given data array.

Parameters

array $data

Return Value

array

protected TestResponse createTestResponse(Response $response)

Create the test response instance from the given response.

Parameters

Response $response

Return Value

TestResponse

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.4/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.html