Skip to content

Commit dc33b4c

Browse files
committed
tests: fix accept header test which fails with Laravel 11
1 parent dbd93e3 commit dc33b4c

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

tests/Integration/AcceptHeaderTest.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,13 @@ public function testAcceptsMiddlewareDoesNotMatch(): void
150150
->acceptsMiddleware('foo', 'bar')
151151
->renderable();
152152

153-
$this->get('/test', ['Accept' => '*/*'])
153+
$response = $this->get('/test', ['Accept' => '*/*']);
154+
155+
$response
154156
->assertStatus(418)
155-
->assertHeader('Content-Type', 'text/html; charset=UTF-8')
156157
->assertSee('teapot');
158+
159+
$this->assertSame('text/html; charset=utf-8', strtolower($response->headers->get('Content-Type')));
157160
}
158161

159162
/**
@@ -167,11 +170,7 @@ public function testAcceptsMiddlewareWhenRouteNotFound(): void
167170

168171
$response = $this->get('/blah', ['Accept' => '*/*']);
169172
$response->assertStatus(404)->assertSee('Not Found');
170-
171-
// @TODO remove once Laravel 8 is no longer supported (8 doesn't add the header)
172-
if (version_compare(Application::VERSION, '9.0.0') >= 0) {
173-
$response->assertHeader('Content-Type', 'text/html; charset=UTF-8');
174-
}
173+
$this->assertSame('text/html; charset=utf-8', strtolower($response->headers->get('Content-Type')));
175174
}
176175

177176
public function testAcceptsMiddlewareWhenRouteNotFoundWithJsonApiMediaType(): void
@@ -223,10 +222,12 @@ public function testAcceptFalse(): void
223222
->accept(fn(\Throwable $ex, Request $request) => false)
224223
->renderable();
225224

226-
$this->get('/test', ['Accept' => '*/*'])
227-
->assertStatus(418)
228-
->assertHeader('Content-Type', 'text/html; charset=UTF-8')
225+
$response = $this->get('/test', ['Accept' => '*/*']);
226+
227+
$response->assertStatus(418)
229228
->assertSee('teapot');
229+
230+
$this->assertSame('text/html; charset=utf-8', strtolower($response->headers->get('Content-Type')));
230231
}
231232

232233
public function testAcceptFalseWithJsonApiAcceptHeader(): void
@@ -279,9 +280,12 @@ public function testMultipleAcceptCallbacks2(): void
279280

280281
public function testHtml(): void
281282
{
282-
$this->get('/test', ['Accept' => '*/*'])
283+
$response = $this->get('/test', ['Accept' => '*/*']);
284+
285+
$response
283286
->assertStatus(418)
284-
->assertHeader('Content-Type', 'text/html; charset=UTF-8')
285287
->assertSee('teapot');
288+
289+
$this->assertSame('text/html; charset=utf-8', strtolower($response->headers->get('Content-Type')));
286290
}
287291
}

0 commit comments

Comments
 (0)