function ExceptionHandlingTest::testHtml404
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::testHtml404()
- 10 core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::testHtml404()
- 11.x core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::testHtml404()
Tests the exception handling for HTML and 404 status code.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Routing/ ExceptionHandlingTest.php, line 98
Class
- ExceptionHandlingTest
- Tests the exception handling for various cases.
Namespace
Drupal\KernelTests\Core\RoutingCode
public function testHtml404() {
$request = Request::create('/not-found');
$request->setFormat('html', [
'text/html',
]);
/** @var \Symfony\Component\HttpKernel\HttpKernelInterface $kernel */
$kernel = \Drupal::getContainer()->get('http_kernel');
$response = $kernel->handle($request)
->prepare($request);
$this->assertEqual($response->getStatusCode(), Response::HTTP_NOT_FOUND);
$this->assertEqual($response->headers
->get('Content-type'), 'text/html; charset=UTF-8');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.