From d43d78c5b843af401908e1c79fdbbc7b13715e5b Mon Sep 17 00:00:00 2001 From: Henk Poley Date: Thu, 15 Jan 2026 13:21:08 +0100 Subject: [PATCH] Make \Illuminate\Testing\TestResponse::assertHeader() case insensitive I bumped into a PhpUnit error today when asserting the response has the correct header: ```php $response->assertHeader('content-type', 'text/html; charset=UTF-8'); ``` PhpUnit error: ``` Header [content-type] was found, but value [text/html; charset=utf-8] does not match [text/html; charset=UTF-8]. Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'text/html; charset=UTF-8' +'text/html; charset=utf-8' [..paths omitted..] ``` It might be that `redirect('/some/path')` fairly recently changed from UTF-8 to utf-8 due to HPACK/QPACK normalisation rules. But it broke some of my tests. In principle these HTTP headers are case-insensitive, so this change to `\Illuminate\Testing\TestResponse::assertHeader()` makes sense. Let me know if you agree, or you want it fixed in another way. --- TestResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestResponse.php b/TestResponse.php index f391bc7..4c5939f 100644 --- a/TestResponse.php +++ b/TestResponse.php @@ -373,7 +373,7 @@ public function assertHeader($headerName, $value = null) $actual = $this->headers->get($headerName); if (! is_null($value)) { - PHPUnit::withResponse($this)->assertEquals( + PHPUnit::withResponse($this)->assertEqualsIgnoringCase( $value, $this->headers->get($headerName), "Header [{$headerName}] was found, but value [{$actual}] does not match [{$value}]." );