Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / KernelTests / RequestProcessing / RedirectOnExceptionTest.php
1 <?php
2
3 namespace Drupal\KernelTests\RequestProcessing;
4
5 use Drupal\KernelTests\KernelTestBase;
6 use Symfony\Component\HttpFoundation\Request;
7 use Symfony\Component\HttpFoundation\Response;
8
9 /**
10  * Tests redirects on exception pages.
11  *
12  * @group request_processing
13  */
14 class RedirectOnExceptionTest extends KernelTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['system', 'test_page_test'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26
27     \Drupal::service('router.builder')->rebuild();
28   }
29
30   public function testRedirectOn404() {
31     \Drupal::configFactory()->getEditable('system.site')
32       ->set('page.404', '/test-http-response-exception/' . Response::HTTP_PERMANENTLY_REDIRECT)
33       ->save();
34
35     /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */
36     $http_kernel = \Drupal::service('http_kernel');
37
38     // Foo doesn't exist, so this triggers the 404 page.
39     $request = Request::create('/foo');
40     $response = $http_kernel->handle($request);
41     $this->assertEquals(Response::HTTP_PERMANENTLY_REDIRECT, $response->getStatusCode());
42   }
43
44 }