Skip to content

Commit

Permalink
Merge pull request #11 from teaandcode/develop
Browse files Browse the repository at this point in the history
Merge Develop into Master
  • Loading branch information
knasher committed Jun 22, 2015
2 parents 6f1099f + 6e270ed commit 6ff9655
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[![Code Coverage](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/badges/build.png?b=master)](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/build-status/master)

[![Join the chat at https://gitter.im/teaandcode/behat-guzzle-extension](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/teaandcode/behat-guzzle-extension?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Guzzle extension for Behat is an integration layer between Behat 3.0+ and Guzzle
3.5+ and it provides:

Expand Down
47 changes: 18 additions & 29 deletions src/Behat/GuzzleExtension/Context/GuzzleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,23 @@ public function theResponseContainsTheFollowingValue(TableNode $table)
*
* Example: The the response contains the following values from JSON:
* """
* {
* "name": "Test Name",
* "users": [
* {
* "id": 3
* },
* {
* "id": 6
* }
* ]
* }
* """
* Example: And the response contains the following value from JSON:
* """
* {
* "name": "Test Name"
* }
* """
*
* @param PyStringNode $string Values specified in feature as JSON
Expand All @@ -315,12 +329,10 @@ public function theResponseContainsTheFollowingValue(TableNode $table)
public function theResponseContainsTheFollowingValueFromJSON(
PyStringNode $string
) {
$data = json_decode($string, true);
$item = $this->getGuzzleResult();

$data = $this->addStoredValuesToArray($data);

$this->compareValues($item, $data);
$this->compareValues(
$this->getGuzzleResult(),
json_decode($this->addStoredValues($string->getRaw()), true)
);
}

/**
Expand Down Expand Up @@ -427,27 +439,4 @@ protected function addStoredValues($string)

return $string;
}

/**
* Adds stored values to array
*
* @param array $array Array containing stored field markers
*
* @access protected
* @return array
*/
protected function addStoredValuesToArray($array)
{
foreach ($array as $field => $value) {
if (is_array($value)) {
$value = $this->addStoredValuesToArray($value);
} else {
$value = $this->addStoredValues($value);
}

$array[$field] = $value;
}

return $array;
}
}

0 comments on commit 6ff9655

Please sign in to comment.