function UncaughtExceptionTest::testUncaughtFatalError
Same name in other branches
- 9 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtFatalError()
- 8.9.x core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtFatalError()
- 10 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtFatalError()
Tests displaying an uncaught fatal error.
File
-
core/
tests/ Drupal/ FunctionalTests/ Bootstrap/ UncaughtExceptionTest.php, line 94
Class
- UncaughtExceptionTest
- Tests kernel panic when things are really messed up.
Namespace
Drupal\FunctionalTests\BootstrapCode
public function testUncaughtFatalError() : void {
if (PHP_VERSION_ID >= 80400) {
$fatal_error = [
'%type' => 'TypeError',
'@message' => 'Drupal\\error_test\\Controller\\ErrorTestController::{closure:Drupal\\error_test\\Controller\\ErrorTestController::generateFatalErrors():64}(): Argument #1 ($test) must be of type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 67',
'%function' => 'Drupal\\error_test\\Controller\\ErrorTestController->{closure:Drupal\\error_test\\Controller\\ErrorTestController::generateFatalErrors():64}()',
];
}
else {
$fatal_error = [
'%type' => 'TypeError',
'@message' => 'Drupal\\error_test\\Controller\\ErrorTestController::Drupal\\error_test\\Controller\\{closure}(): Argument #1 ($test) must be of type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 67',
'%function' => 'Drupal\\error_test\\Controller\\ErrorTestController->Drupal\\error_test\\Controller\\{closure}()',
];
}
$this->drupalGet('error-test/generate-fatal-errors');
$this->assertSession()
->statusCodeEquals(500);
$message = new FormattableMarkup('%type: @message in %function (line ', $fatal_error);
$this->assertSession()
->responseContains((string) $message);
$this->assertSession()
->responseContains('<pre class="backtrace">');
// Ensure we are escaping but not double escaping.
$this->assertSession()
->responseContains('>');
$this->assertSession()
->responseNotContains('&gt;');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.