function RedirectOnExceptionTest::testRedirectOn404
Same name in other branches
- 9 core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest::testRedirectOn404()
- 10 core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest::testRedirectOn404()
- 11.x core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest::testRedirectOn404()
File
-
core/
tests/ Drupal/ KernelTests/ RequestProcessing/ RedirectOnExceptionTest.php, line 30
Class
- RedirectOnExceptionTest
- Tests redirects on exception pages.
Namespace
Drupal\KernelTests\RequestProcessingCode
public function testRedirectOn404() {
\Drupal::configFactory()->getEditable('system.site')
->set('page.404', '/test-http-response-exception/' . Response::HTTP_PERMANENTLY_REDIRECT)
->save();
/** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */
$http_kernel = \Drupal::service('http_kernel');
// Foo doesn't exist, so this triggers the 404 page.
$request = Request::create('/foo');
$response = $http_kernel->handle($request);
$this->assertEquals(Response::HTTP_PERMANENTLY_REDIRECT, $response->getStatusCode());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.