Skip to content

Commit

Permalink
Fixed storedValues in JSON issue
Browse files Browse the repository at this point in the history
  • Loading branch information
knasher committed Jun 22, 2015
1 parent 8dca491 commit 6e270ed
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions src/Behat/GuzzleExtension/Context/GuzzleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,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 @@ -441,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 6e270ed

Please sign in to comment.