PHP Class RestContext

Inheritance: extends Behat\Behat\Context\BehatContext
Mostrar archivo Open project: sourcefabric/newscoop Class Usage Examples

Protected Properties

Property Type Description
$access_token string Client access_token
$associative boolean Specifies if the response data should be an associative array or a nested stdClass object hierarchy.
$client Buzz\Browser
$collectedData string Data collected from steps
$headers array Headers
$locations array Locations collected from steps
$requestMethod string
$requestUrl string Used for debugging purpose only.
$response Buzz\Message\Response
$responseData mixed Data decoded from HTTP response.
$responseDecodeException Exception
$responseIsJson boolean

Public Methods

Method Description
__construct ( array $parameters ) Initializes context.
authenitcatedAsWithClient ( string $username, string $password, string $client, $secret ) : void
authenitcatedWith ( $client, $secret ) : void
checkItemsOrder ( string $order ) : void
collectData ( $dataKey, Behat\Gherkin\Node\TableNode $data ) : void
collectFakeData ( string $dataKey, Behat\Gherkin\Node\TableNode $data ) : boolean
collectHeaders ( $key, $value ) : void
collectLocations ( $locationIndex ) : boolean
echoLastResponse ( ) : void
fieldIsOfTypeWithValue ( string $fieldName, string $type, string $fieldValue ) : void
getResponse ( ) : Guzzle\Http\Message\Response Return the response object.
getResponseData ( ) : mixed Return the response data.
iRequest ( string $pageUrl ) : void
iSubmitDataTo ( $dataKey, string $pageUrl ) : void
processPageUrl ( $pageUrl )
processResponse ( Buzz\Message\Response $response = null, boolean $asJson = true ) : void This public method is also for other context(s) to process REST API call and inject response into this context.
saveFieldValueUnderLocation ( string $fieldName, string $locationIndex ) : Behat\Behat\Context\Step\Then | void
thatIWantToDelete ( ) : void
thatIWantToFind ( ) : void
thatIWantToLink ( ) : void
thatIWantToMakeANew ( ) : void
thatIWantToUnlink ( ) : void
thatIWantToUpdate ( ) : void
theResponseHasAField ( string $name ) : void
theResponseIsJson ( string $notJson = '' ) : void
theResponseShouldBe ( string $string ) : void
theResponseShouldContain ( string $str ) : void
theResponseShouldNotHaveAField ( string $name ) : void
theResponseStatusCodeShouldBe ( integer $httpStatus ) : void
valueOfTheFieldEquals ( string $fieldName, string $fieldValue ) : void

Protected Methods

Method Description
decodeJson ( string $string ) : mixed Decode JSON string.
processResponseBody ( string $jsonData, boolean $asJson = true ) : void Process response body. This method may also be used by other context(s) to process REST API call and inject response body into this context by using 2nd parameter $asJson.

Private Methods

Method Description
extractValueByGivenLocation ( $fieldValue )

Method Details

__construct() public method

Every scenario gets it's own context object.
public __construct ( array $parameters )
$parameters array Context parameters (set them up through behat.yml)

authenitcatedAsWithClient() public method

public authenitcatedAsWithClient ( string $username, string $password, string $client, $secret ) : void
$username string
$password string
$client string
return void

authenitcatedWith() public method

public authenitcatedWith ( $client, $secret ) : void
return void

checkItemsOrder() public method

public checkItemsOrder ( string $order ) : void
$order string
return void

collectData() public method

public collectData ( $dataKey, Behat\Gherkin\Node\TableNode $data ) : void
$data Behat\Gherkin\Node\TableNode
return void

collectFakeData() public method

public collectFakeData ( string $dataKey, Behat\Gherkin\Node\TableNode $data ) : boolean
$dataKey string
$data Behat\Gherkin\Node\TableNode
return boolean

collectHeaders() public method

public collectHeaders ( $key, $value ) : void
return void

collectLocations() public method

public collectLocations ( $locationIndex ) : boolean
return boolean

decodeJson() protected method

Decode JSON string.
See also: http://www.php.net/json_last_error
protected decodeJson ( string $string ) : mixed
$string string A JSON string.
return mixed

echoLastResponse() public method

public echoLastResponse ( ) : void
return void

fieldIsOfTypeWithValue() public method

public fieldIsOfTypeWithValue ( string $fieldName, string $type, string $fieldValue ) : void
$fieldName string
$type string
$fieldValue string
return void

getResponse() public method

This public method is also for other context(s) to get and process REST API response.
public getResponse ( ) : Guzzle\Http\Message\Response
return Guzzle\Http\Message\Response

getResponseData() public method

This public method is also for other context(s) to get and process REST API response.
public getResponseData ( ) : mixed
return mixed

iRequest() public method

public iRequest ( string $pageUrl ) : void
$pageUrl string
return void

iSubmitDataTo() public method

public iSubmitDataTo ( $dataKey, string $pageUrl ) : void
$pageUrl string
return void

processPageUrl() public method

public processPageUrl ( $pageUrl )

processResponse() public method

This public method is also for other context(s) to process REST API call and inject response into this context.
public processResponse ( Buzz\Message\Response $response = null, boolean $asJson = true ) : void
$response Buzz\Message\Response
$asJson boolean Process the response as JSON or not.
return void

processResponseBody() protected method

Process response body. This method may also be used by other context(s) to process REST API call and inject response body into this context by using 2nd parameter $asJson.
protected processResponseBody ( string $jsonData, boolean $asJson = true ) : void
$jsonData string
$asJson boolean
return void

saveFieldValueUnderLocation() public method

public saveFieldValueUnderLocation ( string $fieldName, string $locationIndex ) : Behat\Behat\Context\Step\Then | void
$fieldName string
$locationIndex string
return Behat\Behat\Context\Step\Then | void

thatIWantToDelete() public method

public thatIWantToDelete ( ) : void
return void

thatIWantToFind() public method

public thatIWantToFind ( ) : void
return void

thatIWantToMakeANew() public method

public thatIWantToMakeANew ( ) : void
return void

thatIWantToUpdate() public method

public thatIWantToUpdate ( ) : void
return void

theResponseHasAField() public method

public theResponseHasAField ( string $name ) : void
$name string
return void

theResponseIsJson() public method

public theResponseIsJson ( string $notJson = '' ) : void
$notJson string
return void

theResponseShouldBe() public method

public theResponseShouldBe ( string $string ) : void
$string string
return void

theResponseShouldContain() public method

public theResponseShouldContain ( string $str ) : void
$str string
return void

theResponseShouldNotHaveAField() public method

public theResponseShouldNotHaveAField ( string $name ) : void
$name string
return void

theResponseStatusCodeShouldBe() public method

public theResponseStatusCodeShouldBe ( integer $httpStatus ) : void
$httpStatus integer
return void

valueOfTheFieldEquals() public method

public valueOfTheFieldEquals ( string $fieldName, string $fieldValue ) : void
$fieldName string
$fieldValue string
return void

Property Details

$access_token protected_oe property

Client access_token
protected string $access_token
return string

$associative protected_oe property

Specifies if the response data should be an associative array or a nested stdClass object hierarchy.
protected bool $associative
return boolean

$client protected_oe property

protected Browser,Buzz $client
return Buzz\Browser

$collectedData protected_oe property

Data collected from steps
protected string $collectedData
return string

$headers protected_oe property

Headers
protected array $headers
return array

$locations protected_oe property

Locations collected from steps
protected array $locations
return array

$requestMethod protected_oe property

protected string $requestMethod
return string

$requestUrl protected_oe property

Used for debugging purpose only.
protected string $requestUrl
return string

$response protected_oe property

protected Response,Buzz\Message $response
return Buzz\Message\Response

$responseData protected_oe property

Data decoded from HTTP response.
protected mixed $responseData
return mixed

$responseDecodeException protected_oe property

protected Exception $responseDecodeException
return Exception

$responseIsJson protected_oe property

protected bool $responseIsJson
return boolean