diff --git a/src/Behat/GuzzleExtension/Context/GuzzleContext.php b/src/Behat/GuzzleExtension/Context/GuzzleContext.php index a9ed341..9295b16 100644 --- a/src/Behat/GuzzleExtension/Context/GuzzleContext.php +++ b/src/Behat/GuzzleExtension/Context/GuzzleContext.php @@ -51,6 +51,11 @@ public function __construct(array $users = array()) /** * Calls specified command * + * Example: Given I authenticated as "bruce.wayne" + * Example: When I authenticate as "bruce.wayne" + * + * @param string $user Key from users array to identify user + * * @Given /^I authenticated as "(\S+)"$/ * @When /^I authenticate as "(\S+)"$/ */ @@ -71,6 +76,11 @@ public function iAuthenticateAs($user) /** * Calls specified command * + * Example: Given I called "getHeroesList" + * Example: When I call "getHeroesList" + * + * @param string $command Command in service descriptions file + * * @Given /^I called "(\S+)"$/ * @When /^I call "(\S+)"$/ */ @@ -82,6 +92,40 @@ public function iCallCommand($command) /** * Calls specified command with text * + * Example: Given I called "postCertificates" with the following body text: + * """ + * + *
+ * + * + * ... + * ... + * + * + * ... + * ... + * + * + * """ + * Example: When I call "postCertificates" with the following body text: + * """ + * + *
+ * + * + * ... + * ... + * + * + * ... + * ... + * + * + * """ + * + * @param string $command Command in service descriptions file + * @param PyStringNode $string Text specified in feature + * * @Given /^I called "(\S+)" with the following body text:$/ * @When /^I call "(\S+)" with the following body text:$/ */ @@ -98,6 +142,16 @@ public function iCallCommandWithBodyText($command, PyStringNode $string) /** * Calls specified command with fields * + * Example: Given I called "putHero" with the following values: + * | description | I am not batman | + * | id | 1 | + * Example: When I call "putHero" with the following values: + * | description | I am not batman | + * | id | 1 | + * + * @param string $command Command in service descriptions file + * @param TableNode $table Values specified in feature + * * @Given /^I called "(\S+)" with the following value(s?):$/ * @When /^I call "(\S+)" with the following value(s?):$/ */ @@ -118,6 +172,28 @@ public function iCallCommandWithValue($command, TableNode $table) /** * Calls specified command with fields * + * Example: Given I called "putHero" with the following values from JSON: + * """ + * [ + * { + * "description": "I am not batman", + * "id": 1 + * } + * ] + * """ + * Example: When I call "putHero" with the following values from JSON: + * """ + * [ + * { + * "description": "I am not batman", + * "id": 1 + * } + * ] + * """ + * + * @param string $command Command in service descriptions file + * @param PyStringNode $string Values specified in feature as JSON + * * @Given /^I called "(\S+)" with the following value(s?) from JSON:$/ * @When /^I call "(\S+)" with the following value(s?) from JSON:$/ */ @@ -132,6 +208,13 @@ public function iCallCommandWithValueFromJSON( } /** + * Checks status code in reponse + * + * Example: And I get a response with a status code of 503 + * Example: Then I get a response with a status code of 503 + * + * @param string $code Expected HTTP status code + * * @Then I get a response with a status code of :code */ public function iGetAResponseWithAStatusCodeOf($code) @@ -147,6 +230,11 @@ public function iGetAResponseWithAStatusCodeOf($code) } /** + * Checks response is successful + * + * Example: And I get successful response + * Example: Then I get successful response + * * @Then I get a successful response */ public function iGetASuccessfulResponse() @@ -160,6 +248,13 @@ public function iGetASuccessfulResponse() } /** + * Checks response is unsuccessful with specified status code + * + * Example: And I get unsuccessful response with a status code of 503 + * Example: Then I get unsuccessful response with a status code of 503 + * + * @param string $code Expected HTTP status code + * * @Then I get an unsuccessful response with a status code of :code */ public function iGetAnUnsuccessfulResponseWithAStatusCodeOf($code) @@ -172,6 +267,17 @@ public function iGetAnUnsuccessfulResponseWithAStatusCodeOf($code) } /** + * Check response contains specified values + * + * Example: Then the response contains the following values: + * | id | 27 | + * | importance | 3 | + * | username | bruce.wayne | + * Example: And the response contains the following value: + * | id | 27 | + * + * @param TableNode $table Values specified in feature + * * @Then the response contains the following value(s): */ public function theResponseContainsTheFollowingValue(TableNode $table) @@ -192,6 +298,18 @@ public function theResponseContainsTheFollowingValue(TableNode $table) } /** + * + * Example: Then the response contains 2 resources with the following data: + * | id | importance | username | + * | 27 | 3 | bruce.wayne | + * | 34 | 2 | clark.kent | + * Example: And the response contains 1 resource with the following data: + * | id | importance | username | + * | 27 | 3 | bruce.wayne | + * + * @param integer $count Number of resources received + * @param TableNode $table Values specified in feature + * * @Then the response contains :count resource(s) with the following data: */ public function theResponseContainsResourceWithTheFollowingData( @@ -216,6 +334,13 @@ public function theResponseContainsResourceWithTheFollowingData( } /** + * Store response for later use in the scenario + * + * Example: Then the response is stored as "heroes" + * Example: And the response is stored as "heroes" + * + * @param string $name Name to use when storing response + * * @Then /^the response is stored as "(\S+)"$/ */ public function theResponseIsStored($name)