Skip to content

Commit

Permalink
Merge branch 'getsaucey-develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
knasher committed Apr 8, 2015
2 parents fb0fdf0 + 20aae1d commit 552d675
Showing 1 changed file with 125 additions and 0 deletions.
125 changes: 125 additions & 0 deletions src/Behat/GuzzleExtension/Context/GuzzleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+)"$/
*/
Expand All @@ -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+)"$/
*/
Expand All @@ -82,6 +92,40 @@ public function iCallCommand($command)
/**
* Calls specified command with text
*
* Example: Given I called "postCertificates" with the following body text:
* """
* <?xml version="1.0" encoding="UTF-8"?>
* <Header userId="1" />
* <Body>
* <Document type="certificate" encoding="uft-8" noPages="1">
* <XML>...</XML>
* <Image>...</Image>
* </Document>
* <Document type="certificate" encoding="uft-8" noPages="1">
* <XML>...</XML>
* <Image>...</Image>
* </Document>
* </Body>
* """
* Example: When I call "postCertificates" with the following body text:
* """
* <?xml version="1.0" encoding="UTF-8"?>
* <Header userId="1" />
* <Body>
* <Document type="certificate" encoding="uft-8" noPages="1">
* <XML>...</XML>
* <Image>...</Image>
* </Document>
* <Document type="certificate" encoding="uft-8" noPages="1">
* <XML>...</XML>
* <Image>...</Image>
* </Document>
* </Body>
* """
*
* @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:$/
*/
Expand All @@ -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?):$/
*/
Expand All @@ -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:$/
*/
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit 552d675

Please sign in to comment.