From 12d8a9716653cff3a3d56a43297773263f94e481 Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Mon, 22 Jun 2015 13:19:46 +0000 Subject: [PATCH 1/3] Added Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cdf53e4..b26ef35 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Behat Guzzle Extension +[![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) + [![Build Status](https://travis-ci.org/teaandcode/behat-guzzle-extension.svg?branch=master)](https://travis-ci.org/teaandcode/behat-guzzle-extension) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/?branch=master) From b58afda52001b894e440f8b34272a48aa998f908 Mon Sep 17 00:00:00 2001 From: Dave Nash Date: Mon, 22 Jun 2015 21:41:43 +0100 Subject: [PATCH 2/3] Small non-functional updates * Moved location of Gitter badge * Added missing doc examples from new JSON step definition --- README.md | 4 ++-- .../GuzzleExtension/Context/GuzzleContext.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b26ef35..4f00b1e 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Behat Guzzle Extension -[![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) - [![Build Status](https://travis-ci.org/teaandcode/behat-guzzle-extension.svg?branch=master)](https://travis-ci.org/teaandcode/behat-guzzle-extension) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/teaandcode/behat-guzzle-extension/?branch=master) [![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: diff --git a/src/Behat/GuzzleExtension/Context/GuzzleContext.php b/src/Behat/GuzzleExtension/Context/GuzzleContext.php index b42b798..4dcc354 100644 --- a/src/Behat/GuzzleExtension/Context/GuzzleContext.php +++ b/src/Behat/GuzzleExtension/Context/GuzzleContext.php @@ -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 From 6e270ed96c18c493b1c863051f20c7f6da3446e0 Mon Sep 17 00:00:00 2001 From: Dave Nash Date: Mon, 22 Jun 2015 22:35:39 +0100 Subject: [PATCH 3/3] 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; - } }