PHP Class RESTContext, imbo

Inheritance: implements Behat\Behat\Context\Context
Show file Open project: imbo/imbo Class Usage Examples

Protected Properties

Property Type Description
$client Guzzle\Http\Client Guzzle client used to make requests against the httpd
$queryParams array Query parameters for the request
$requestBody string Optional request body to add to the request
$requestHeaders array Headers for the request
$responses Guzzle\Http\Message\Response[] The current response objects used by the client (populated when the request is sent)

Public Methods

Method Description
__construct ( array $parameters ) Class constructor
appendQueryStringParameter ( $queryParam, $value )
assertEmptyResponseBody ( )
assertEqualResponseHeaders ( Behat\Gherkin\Node\PyStringNode $list )
assertExistingHeaders ( Behat\Gherkin\Node\PyStringNode $list )
assertHeaderDoesNotExist ( $header )
assertHeaderNotSameForPreviousRequests ( $header )
assertMaxAge ( $seconds )
assertMissingHeaders ( Behat\Gherkin\Node\PyStringNode $list )
assertMustRevalidate ( $doesNotHave = false )
assertResponseBody ( $match, Behat\Gherkin\Node\PyStringNode $expected )
assertResponseBodyLength ( $length )
assertResponseHeader ( $header, $match, $value )
assertResponseIsCacheable ( $cacheable = true )
assertResponseStatus ( $status )
attachFileToRequestBody ( $path )
makeSameRequest ( $method )
performRequestWithGivenQueryString ( $path )
request ( $path, $method = 'GET' )
setOverrideMethodHeader ( string $method ) Set method override header used to fake non-standard HTTP verbs
setRequestBody ( Behat\Gherkin\Node\PyStringNode $body )
setRequestHeader ( $header, $value )
setUp ( Behat\Behat\Event\SuiteEvent $event ) Start up the built in httpd in php-5.4
tearDown ( Behat\Behat\Event\SuiteEvent $event ) Collect code coverage after the suite has been run

Protected Methods

Method Description
addHeaderToNextRequest ( string $key, mixed $value ) Add a request header for the next request
getLastResponse ( ) : Guzzle\Http\Message\Response Get the response to the last request made by the Guzzle client
getPreviousCacheControlHeader ( ) : Guzzle\Http\Message\Header\CacheControl Get the cache-control header for the previous response

Private Methods

Method Description
canConnectToHttpd ( string $host, integer $port ) : boolean See if we have an httpd we can connect to
createClient ( ) Create a new HTTP client
getOverrideVerbs ( ) Returns a list of HTTP verbs that we need to do an override of in order to bypass limitations in the built-in PHP HTTP server.
startBuiltInHttpd ( string $host, integer $port, string $documentRoot, string $router, string $httpdLog ) : integer Start the built in httpd in php-5.4

Method Details

__construct() public method

Class constructor
public __construct ( array $parameters )
$parameters array Context parameters

addHeaderToNextRequest() protected method

Add a request header for the next request
protected addHeaderToNextRequest ( string $key, mixed $value )
$key string The name of the header
$value mixed The value of the header

appendQueryStringParameter() public method

public appendQueryStringParameter ( $queryParam, $value )

assertEmptyResponseBody() public method

assertEqualResponseHeaders() public method

public assertEqualResponseHeaders ( Behat\Gherkin\Node\PyStringNode $list )
$list Behat\Gherkin\Node\PyStringNode

assertExistingHeaders() public method

public assertExistingHeaders ( Behat\Gherkin\Node\PyStringNode $list )
$list Behat\Gherkin\Node\PyStringNode

assertHeaderDoesNotExist() public method

public assertHeaderDoesNotExist ( $header )

assertHeaderNotSameForPreviousRequests() public method

assertMaxAge() public method

public assertMaxAge ( $seconds )

assertMissingHeaders() public method

public assertMissingHeaders ( Behat\Gherkin\Node\PyStringNode $list )
$list Behat\Gherkin\Node\PyStringNode

assertMustRevalidate() public method

public assertMustRevalidate ( $doesNotHave = false )

assertResponseBody() public method

public assertResponseBody ( $match, Behat\Gherkin\Node\PyStringNode $expected )
$expected Behat\Gherkin\Node\PyStringNode

assertResponseBodyLength() public method

public assertResponseBodyLength ( $length )

assertResponseHeader() public method

public assertResponseHeader ( $header, $match, $value )

assertResponseIsCacheable() public method

public assertResponseIsCacheable ( $cacheable = true )

assertResponseStatus() public method

public assertResponseStatus ( $status )

attachFileToRequestBody() public method

public attachFileToRequestBody ( $path )

getLastResponse() protected method

Get the response to the last request made by the Guzzle client
protected getLastResponse ( ) : Guzzle\Http\Message\Response
return Guzzle\Http\Message\Response

getPreviousCacheControlHeader() protected method

Get the cache-control header for the previous response
protected getPreviousCacheControlHeader ( ) : Guzzle\Http\Message\Header\CacheControl
return Guzzle\Http\Message\Header\CacheControl The Cache-Control header for the previous response

makeSameRequest() public method

public makeSameRequest ( $method )

performRequestWithGivenQueryString() public method

request() public method

public request ( $path, $method = 'GET' )

setOverrideMethodHeader() public method

Set method override header used to fake non-standard HTTP verbs
public setOverrideMethodHeader ( string $method )
$method string Override method

setRequestBody() public method

public setRequestBody ( Behat\Gherkin\Node\PyStringNode $body )
$body Behat\Gherkin\Node\PyStringNode

setRequestHeader() public method

public setRequestHeader ( $header, $value )

setUp() public static method

Start up the built in httpd in php-5.4
public static setUp ( Behat\Behat\Event\SuiteEvent $event )
$event Behat\Behat\Event\SuiteEvent

tearDown() public static method

Collect code coverage after the suite has been run
public static tearDown ( Behat\Behat\Event\SuiteEvent $event )
$event Behat\Behat\Event\SuiteEvent

Property Details

$client protected property

Guzzle client used to make requests against the httpd
protected Client,Guzzle\Http $client
return Guzzle\Http\Client

$queryParams protected property

Query parameters for the request
protected array $queryParams
return array

$requestBody protected property

Optional request body to add to the request
protected string $requestBody
return string

$requestHeaders protected property

Headers for the request
protected array $requestHeaders
return array

$responses protected property

The current response objects used by the client (populated when the request is sent)
protected Response[],Guzzle\Http\Message $responses
return Guzzle\Http\Message\Response[]