diff --git a/src/RestApiContext.php b/src/RestApiContext.php index 91a9a79..2a43b59 100644 --- a/src/RestApiContext.php +++ b/src/RestApiContext.php @@ -107,9 +107,19 @@ public function theResponseCodeShouldBe($code) */ public function theResponseHeaderShouldHave($headerKey, $expectedValue) { - if (! $this->response->getHeader($headerKey)->hasValue($expectedValue)) { - throw new \mageekguy\atoum\asserter\exception($this->asserter, sprintf('Header "%s" is not containing "%s" in last response.', $headerKey, $expectedValue)); - } + $hasValue = $this->response->getHeader($headerKey)->hasValue($expectedValue); + $this->asserter->boolean($hasValue) + ->isTrue( + sprintf( + 'Header "%s" is not containing in last response: +"%s" +Received: +"%s"', + $headerKey, + $expectedValue, + implode(', ', $this->response->getHeader($headerKey)->toArray()) + ) + ); } /** diff --git a/tests/Units/RestApiContext.php b/tests/Units/RestApiContext.php index fb298e0..7d64681 100644 --- a/tests/Units/RestApiContext.php +++ b/tests/Units/RestApiContext.php @@ -97,6 +97,15 @@ function() use($sut) { $sut->theResponseHeaderShouldHave('foo', 'chuck'); } )->isInstanceOf('\mageekguy\atoum\asserter\exception') + ->hasMessage('Header "foo" is not containing in last response: +"chuck" +Received: +"bar, azerty" +-Expected ++Actual +@@ -1 +1 @@ +-bool(true) ++bool(false)') ; }