diff --git a/spec/Behat/GuzzleExtension/Context/GuzzleContextSpec.php b/spec/Behat/GuzzleExtension/Context/GuzzleContextSpec.php index 68c255e..98202d8 100644 --- a/spec/Behat/GuzzleExtension/Context/GuzzleContextSpec.php +++ b/spec/Behat/GuzzleExtension/Context/GuzzleContextSpec.php @@ -267,4 +267,32 @@ public function it_has_i_call_command_but_response_contains_wrong_resource_count '\Guzzle\Http\Exception\ClientErrorResponseException' )->duringTheResponseContainsResourceWithTheFollowingData(1, $table); } + + public function it_should_retrieve_stored_values_by_key() + { + $client1 = $this->getMockedClient( + new Response( + 200, + array( + 'Content-Type' => 'application/json' + ), + '[{"foo":"bar"},{"foo":"fu"}]' + ) + ); + + $output = new TableNode( + array( + array('foo'), + array('bar'), + array('fu') + ) + ); + + $this->setGuzzleClient($client1); + $this->iCallCommand('Mock'); + $this->theResponseContainsResourceWithTheFollowingData(2, $output); + $this->theResponseIsStored('test'); + + $this->getStoredValue('test'); + } } diff --git a/src/Behat/GuzzleExtension/Context/GuzzleContext.php b/src/Behat/GuzzleExtension/Context/GuzzleContext.php index c926899..92dd16a 100644 --- a/src/Behat/GuzzleExtension/Context/GuzzleContext.php +++ b/src/Behat/GuzzleExtension/Context/GuzzleContext.php @@ -336,7 +336,7 @@ public function theResponseContainsTheFollowingValueFromJSON( } /** - * + * * Example: Then the response contains 2 resources with the following data: * | id | importance | username | * | 27 | 3 | bruce.wayne | @@ -386,6 +386,19 @@ public function theResponseIsStored($name) $this->storedResult[$name] = $this->getGuzzleResult(); } + /** + * Get stored value + * + * @param string $name Name used when storing response + * + * @access public + * @return mixed + */ + public function getStoredValue($name) + { + return $this->storedResult[$name]; + } + /** * Cast value into type depending on content *