protected function ExceptionHandlingTest::doTest404Route in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::doTest404Route()
- 10 core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::doTest404Route()
Sets the given path to use as the 404 page and triggers a 404.
Parameters
string $path:
Return value
\Drupal\Core\Render\HtmlResponse
See also
\Drupal\system\Tests\Routing\ExceptionHandlingTest::testExceptionResponseGeneratedForOriginalRequest()
1 call to ExceptionHandlingTest::doTest404Route()
- ExceptionHandlingTest::testExceptionResponseGeneratedForOriginalRequest in core/tests/ Drupal/ KernelTests/ Core/ Routing/ ExceptionHandlingTest.php 
- Tests that the exception response is executed in the original context.
File
- core/tests/ Drupal/ KernelTests/ Core/ Routing/ ExceptionHandlingTest.php, line 136 
Class
- ExceptionHandlingTest
- Tests the exception handling for various cases.
Namespace
Drupal\KernelTests\Core\RoutingCode
protected function doTest404Route($path) {
  $this
    ->config('system.site')
    ->set('page.404', $path)
    ->save();
  $request = Request::create('/not-found');
  $request
    ->setFormat('html', [
    'text/html',
  ]);
  /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $kernel */
  $kernel = \Drupal::getContainer()
    ->get('http_kernel');
  return $kernel
    ->handle($request)
    ->prepare($request);
}