PHP Class blink\testing\RequestActor

Since: 0.3.0
Inheritance: use trait blink\testing\AuthTrait
Show file Open project: bixuehujin/blink

Protected Properties

Property Type Description
$app
$phpunit
$request blink\http\Request
$response blink\http\Response

Public Methods

Method Description
__construct ( PHPUnit_Framework_TestCase $phpunit, Application $app )
accepts ( $accepts )
asJson ( ) : mixed Returns the response as json.
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.
dumpCookies ( ) Dump the response cookies for debug purpose.
dumpHeaders ( ) Dump the response headers for debug purpose.
dumpJson ( ) Dump the response json for debug purpose.
get ( string $uri, array $headers = [] ) Visit the given URI with a GET 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.
seeContent ( string $content ) Asserts that the content of the response matches the given content.
seeCookie ( string $name, mixed $value = null ) Asserts that the response contains the given cookie and equals the optional value.
seeHeader ( string $name, mixed $value = null ) Asserts that the response contains the given header and equals the optional value.
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.
seeStatusCode ( integer $status ) Asserts that the status code of the response matches the given code.
withFiles ( array $files ) Send the request with specified files.
withHeaders ( array $headers = [] )
withJson ( )

Protected Methods

Method Description
doRequest ( $method, $uri, $query = '', $cookies = [], $files = [], $headers = [], $content = null )
formatToExpectedJson ( $key, $value )
isJsonMessage ( blink\http\HeaderBag $headers )
isVerbose ( )
normalizeUri ( $uri )
seeJsonContains ( array $data, boolean $negate = false ) Assert that the response contains the given JSON.

Private Methods

Method Description
isAssoc ( array $array ) : boolean Determines if an array is associative.
sortRecursive ( array $array ) : array Recursively sort an array by keys and values.

Method Details

__construct() public method

public __construct ( PHPUnit_Framework_TestCase $phpunit, Application $app )
$phpunit PHPUnit_Framework_TestCase
$app blink\core\Application

accepts() public method

public accepts ( $accepts )

asJson() public method

Returns the response as json.
public asJson ( ) : mixed
return mixed

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

doRequest() protected method

protected doRequest ( $method, $uri, $query = '', $cookies = [], $files = [], $headers = [], $content = null )

dontSeeJson() public method

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

dumpCookies() public method

Dump the response cookies for debug purpose.
public dumpCookies ( )

dumpHeaders() public method

Dump the response headers for debug purpose.
public dumpHeaders ( )

dumpJson() public method

Dump the response json for debug purpose.
public dumpJson ( )

formatToExpectedJson() protected method

protected formatToExpectedJson ( $key, $value )

get() public method

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

isJsonMessage() protected method

protected isJsonMessage ( blink\http\HeaderBag $headers )
$headers blink\http\HeaderBag

isVerbose() protected method

protected isVerbose ( )

normalizeUri() protected method

protected normalizeUri ( $uri )

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

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

seeContent() public method

Asserts that the content of the response matches the given content.
public seeContent ( string $content )
$content string

seeCookie() public method

Asserts that the response contains the given cookie and equals the optional value.
public seeCookie ( string $name, mixed $value = null )
$name string
$value mixed

seeHeader() public method

Asserts that the response contains the given header and equals the optional value.
public seeHeader ( string $name, mixed $value = null )
$name 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() public method

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

withFiles() public method

Send the request with specified files.
public withFiles ( array $files )
$files array

withHeaders() public method

public withHeaders ( array $headers = [] )
$headers array

withJson() public method

public withJson ( )

Property Details

$app protected property

protected $app

$phpunit protected property

protected $phpunit

$request protected property

protected Request,blink\http $request
return blink\http\Request

$response protected property

protected Response,blink\http $response
return blink\http\Response