diff --git a/src/Context/RestContext.php b/src/Context/RestContext.php index 7e837b10..cf78a1e0 100644 --- a/src/Context/RestContext.php +++ b/src/Context/RestContext.php @@ -112,6 +112,21 @@ public function theHeaderShouldBeEqualTo($name, $value) ); } + /** + * Checks, whether the header name is not equal to given text + * + * @Then the header :name should not be equal to :value + */ + public function theHeaderShouldNotBeEqualTo($name, $value) { + $actual = $this->getSession()->getResponseHeader($name); + if (strtolower($value) == strtolower($actual)) { + throw new ExpectationException( + "The header '$name' is equal to '$actual'", + $this->getSession()->getDriver() + ); + } + } + /** * Checks, whether the header name contains the given text * diff --git a/tests/features/rest.feature b/tests/features/rest.feature index 33800a74..59ba4530 100644 --- a/tests/features/rest.feature +++ b/tests/features/rest.feature @@ -4,6 +4,7 @@ Feature: Testing RESTContext When I send a GET request to "rest/index.php" And the header "Content-Type" should contain "text" And the header "Content-Type" should be equal to "text/html; charset=UTF-8" + And the header "Content-Type" should not be equal to "x-test/no-such-type" And the header "Content-Type" should not contain "text/json" And the header "xxx" should not exist And the response should expire in the future