RedirectOnExceptionTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php
View source
<?php
namespace Drupal\KernelTests\RequestProcessing;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class RedirectOnExceptionTest extends KernelTestBase {
protected static $modules = [
'system',
'test_page_test',
];
public function testRedirectOn404() {
\Drupal::configFactory()
->getEditable('system.site')
->set('page.404', '/test-http-response-exception/' . Response::HTTP_PERMANENTLY_REDIRECT)
->save();
$http_kernel = \Drupal::service('http_kernel');
$request = Request::create('/foo');
$response = $http_kernel
->handle($request);
$this
->assertEquals(Response::HTTP_PERMANENTLY_REDIRECT, $response
->getStatusCode());
}
}