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.
$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.
protected string prepareUrlForRequest(string $uri)
Turn the given URI into a fully qualified URL.
protected array transformHeadersToServerVars(array $headers)
Transform headers array to array of $SERVER vars with HTTP* format.
protected string formatServerHeaderKey(string $name)
Format the header name for the server array.
protected array extractFilesFromDataArray(array $data)
Extract the file uploads from the given data array.
protected TestResponse createTestResponse(Response $response)
Create the test response instance from the given response.
© 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