From 6e270ed96c18c493b1c863051f20c7f6da3446e0 Mon Sep 17 00:00:00 2001 From: Dave Nash Date: Mon, 22 Jun 2015 22:35:39 +0100 Subject: [PATCH] Fixed storedValues in JSON issue --- .../GuzzleExtension/Context/GuzzleContext.php | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/Behat/GuzzleExtension/Context/GuzzleContext.php b/src/Behat/GuzzleExtension/Context/GuzzleContext.php index 4dcc354..c926899 100644 --- a/src/Behat/GuzzleExtension/Context/GuzzleContext.php +++ b/src/Behat/GuzzleExtension/Context/GuzzleContext.php @@ -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) + ); } /** @@ -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; - } }