PHP Trait Laravel\Lumen\Testing\Concerns\MakesHttpRequests

Show file Open project: laravel/lumen-framework

Protected Properties

Property Type Description
$currentUri string The current URL being viewed.
$response Illuminate\Http\Response The last response returned by the application.

Public Methods

Method Description
assertResponseOk ( ) : void Assert that the client response has an OK status code.
assertResponseStatus ( integer $code ) : void Assert that the client response has a given code.
call ( string $method, string $uri, array $parameters = [], array $cookies = [], array $files = [], array $server = [], string $content = null ) : Illuminate\Http\Response Call the given URI and return the Response.
delete ( string $uri, array $data = [], array $headers = [] ) Visit the given URI with a DELETE request.
dontSeeJson ( array $data = null ) Assert that the response doesn't contain JSON.
get ( string $uri, array $headers = [] ) Visit the given URI with a GET request.
handle ( Illuminate\Http\Request $request ) Send the given request through the application.
json ( string $method, string $uri, array $data = [], array $headers = [] ) Visit the given URI with a JSON request.
patch ( string $uri, array $data = [], array $headers = [] ) Visit the given URI with a PATCH request.
post ( string $uri, array $data = [], array $headers = [] ) Visit the given URI with a POST request.
put ( string $uri, array $data = [], array $headers = [] ) Visit the given URI with a PUT request.
seeJson ( array $data = null, boolean $negate = false ) Assert that the response contains JSON.
seeJsonEquals ( array $data ) Assert that the response contains an exact JSON array.
seeJsonStructure ( array $structure = null, array | null $responseData = null ) Assert that the JSON response has a given structure.
withoutMiddleware ( ) Disable middleware for the test.

Protected Methods

Method Description
formatToExpectedJson ( string $key, mixed $value ) : string Format the given key and value into a JSON string for expectation checks.
prepareUrlForRequest ( string $uri ) : string Turn the given URI into a fully qualified URL.
receiveJson ( array | null $data = null ) Assert that the response contains JSON.
seeHeader ( string $headerName, mixed $value = null ) Asserts that the response contains the given header and equals the optional value.
seeJsonContains ( array $data, boolean $negate = false ) Assert that the response contains the given JSON.
seeStatusCode ( integer $status ) Asserts that the status code of the response matches the given code.
shouldReturnJson ( array $data = null ) Assert that the response contains JSON.
transformHeadersToServerVars ( array $headers ) : array Transform headers array to array of $_SERVER vars with HTTP_* format.

Method Details

assertResponseOk() public method

Assert that the client response has an OK status code.
public assertResponseOk ( ) : void
return void

assertResponseStatus() public method

Assert that the client response has a given code.
public assertResponseStatus ( integer $code ) : void
$code integer
return void

call() public method

Call the given URI and return the Response.
public call ( string $method, string $uri, array $parameters = [], array $cookies = [], array $files = [], array $server = [], string $content = null ) : Illuminate\Http\Response
$method string
$uri string
$parameters array
$cookies array
$files array
$server array
$content string
return Illuminate\Http\Response

delete() public method

Visit the given URI with a DELETE request.
public delete ( string $uri, array $data = [], array $headers = [] )
$uri string
$data array
$headers array

dontSeeJson() public method

Assert that the response doesn't contain JSON.
public dontSeeJson ( array $data = null )
$data array

formatToExpectedJson() protected method

Format the given key and value into a JSON string for expectation checks.
protected formatToExpectedJson ( string $key, mixed $value ) : string
$key string
$value mixed
return string

get() public method

Visit the given URI with a GET request.
public get ( string $uri, array $headers = [] )
$uri string
$headers array

handle() public method

This method allows you to fully customize the entire Request object.
public handle ( Illuminate\Http\Request $request )
$request Illuminate\Http\Request

json() public method

Visit the given URI with a JSON request.
public json ( string $method, string $uri, array $data = [], array $headers = [] )
$method string
$uri string
$data array
$headers array

patch() public method

Visit the given URI with a PATCH request.
public patch ( string $uri, array $data = [], array $headers = [] )
$uri string
$data array
$headers array

post() public method

Visit the given URI with a POST request.
public post ( string $uri, array $data = [], array $headers = [] )
$uri string
$data array
$headers array

prepareUrlForRequest() protected method

Turn the given URI into a fully qualified URL.
protected prepareUrlForRequest ( string $uri ) : string
$uri string
return string

put() public method

Visit the given URI with a PUT request.
public put ( string $uri, array $data = [], array $headers = [] )
$uri string
$data array
$headers array

receiveJson() protected method

Assert that the response contains JSON.
protected receiveJson ( array | null $data = null )
$data array | null

seeHeader() protected method

Asserts that the response contains the given header and equals the optional value.
protected seeHeader ( string $headerName, mixed $value = null )
$headerName string
$value mixed

seeJson() public method

Assert that the response contains JSON.
public seeJson ( array $data = null, boolean $negate = false )
$data array
$negate boolean

seeJsonContains() protected method

Assert that the response contains the given JSON.
protected seeJsonContains ( array $data, boolean $negate = false )
$data array
$negate boolean

seeJsonEquals() public method

Assert that the response contains an exact JSON array.
public seeJsonEquals ( array $data )
$data array

seeJsonStructure() public method

Assert that the JSON response has a given structure.
public seeJsonStructure ( array $structure = null, array | null $responseData = null )
$structure array
$responseData array | null

seeStatusCode() protected method

Asserts that the status code of the response matches the given code.
protected seeStatusCode ( integer $status )
$status integer

shouldReturnJson() protected method

Assert that the response contains JSON.
protected shouldReturnJson ( array $data = null )
$data array

transformHeadersToServerVars() protected method

Transform headers array to array of $_SERVER vars with HTTP_* format.
protected transformHeadersToServerVars ( array $headers ) : array
$headers array
return array

withoutMiddleware() public method

Disable middleware for the test.
public withoutMiddleware ( )

Property Details

$currentUri protected property

The current URL being viewed.
protected string $currentUri
return string

$response protected property

The last response returned by the application.
protected Response,Illuminate\Http $response
return Illuminate\Http\Response