diff --git a/src/Knp/FriendlyContexts/Context/ApiContext.php b/src/Knp/FriendlyContexts/Context/ApiContext.php index 8fc8ca00..eb725a4e 100644 --- a/src/Knp/FriendlyContexts/Context/ApiContext.php +++ b/src/Knp/FriendlyContexts/Context/ApiContext.php @@ -198,7 +198,7 @@ public function iShouldReceiveResponse($httpCode, $shortType = null) )); } } - + /** * @Then /^the response should contains the following headers:?$/ */ @@ -209,10 +209,26 @@ public function theResponseShouldContainsHeaders(TableNode $headerTable) } $expectedHeaders = $headerTable->getRowsHash(); - $this->getAsserter()->assertArrayContains( - $expectedHeaders, - $this->response->getHeaders() - ); + $existingHeaders = $this->response->getHeaders()->toArray(); + + foreach ($expectedHeaders as $key => $value) { + if (false === array_key_exists($key, $existingHeaders)) { + throw new \Exception(sprintf( + 'No header names "%s" found. "%s" available.', + $key, + implode('", "', array_keys($existingHeaders)) + )); + } + $real = $existingHeaders[$key]; + array_map('trim', $real); + sort($real); + + $expected = array($value); + array_map('trim', $expected); + sort($expected); + + $this->getAsserter()->assertArrayEquals($expected, $real); + } } /**