From ea84ec6b593a2607d0aa754dbde9bf17c7602f13 Mon Sep 17 00:00:00 2001 From: Quentin Barloy Date: Mon, 8 Aug 2022 14:53:48 +0200 Subject: [PATCH] [feature] Assert that an header is not present (#98) --- README.md | 1 + src/Browser/KernelBrowser.php | 2 +- tests/KernelBrowserTests.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ef72488..754214b 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,7 @@ $browser ->assertRedirected() // 3xx status code ->assertHeaderEquals('Content-Type', 'text/html; charset=UTF-8') ->assertHeaderContains('Content-Type', 'html') + ->assertHeaderEquals('X-Not-Present-Header', null) // helpers for quickly checking the content type ->assertJson() diff --git a/src/Browser/KernelBrowser.php b/src/Browser/KernelBrowser.php index 120810f..69c487c 100644 --- a/src/Browser/KernelBrowser.php +++ b/src/Browser/KernelBrowser.php @@ -414,7 +414,7 @@ final public function assertRedirected(): self /** * @return static */ - final public function assertHeaderEquals(string $header, string $expected): self + final public function assertHeaderEquals(string $header, ?string $expected): self { $this->session()->assert()->responseHeaderEquals($header, $expected); diff --git a/tests/KernelBrowserTests.php b/tests/KernelBrowserTests.php index 610c94a..24c70be 100644 --- a/tests/KernelBrowserTests.php +++ b/tests/KernelBrowserTests.php @@ -233,6 +233,7 @@ public function response_header_assertions(): void ->visit('/page1') ->assertHeaderEquals('Content-Type', 'text/html; charset=UTF-8') ->assertHeaderContains('Content-Type', 'text/html') + ->assertHeaderEquals('X-Not-Present-Header', null) ; }