From fde2f054bf8af252d48aab21501620822e9bbae9 Mon Sep 17 00:00:00 2001 From: Laurie Plociennik Date: Tue, 17 Oct 2017 21:40:45 +0200 Subject: [PATCH] Behat/WebApiExtension#6 Add step definition to access header values --- src/Context/WebApiContext.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Context/WebApiContext.php b/src/Context/WebApiContext.php index fa008df..7b79cf1 100644 --- a/src/Context/WebApiContext.php +++ b/src/Context/WebApiContext.php @@ -222,6 +222,19 @@ public function theResponseCodeShouldBe($code) Assertions::assertSame($expected, $actual); } + /** + * Checks that the response has specific header key/value + * + * @param string $key header key + * @param string $value header value + * + * @Then the response header :key should be :value + */ + public function theResponseHeaderShouldBe($key, $value) + { + Assertions::assertSame($value, $this->response->getHeader($key)[0]); + } + /** * Checks that response body contains specific text. *