class RedirectOnExceptionTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest
- 10 core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest
- 9 core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest
- 8.9.x core/tests/Drupal/KernelTests/RequestProcessing/RedirectOnExceptionTest.php \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest
Tests redirects on exception pages.
Attributes
#[Group('request_processing')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of RedirectOnExceptionTest
File
-
core/
tests/ Drupal/ KernelTests/ RequestProcessing/ RedirectOnExceptionTest.php, line 16
Namespace
Drupal\KernelTests\RequestProcessingView source
class RedirectOnExceptionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'test_page_test',
];
/**
* Tests redirects with a 404.
*/
public function testRedirectOn404() : void {
\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.