public function UncaughtExceptionTest::testUncaughtException in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtException()
- 9 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtException()
Tests uncaught exception handling when system is in a bad state.
File
- core/
tests/ Drupal/ FunctionalTests/ Bootstrap/ UncaughtExceptionTest.php, line 61
Class
- UncaughtExceptionTest
- Tests kernel panic when things are really messed up.
Namespace
Drupal\FunctionalTests\BootstrapCode
public function testUncaughtException() {
$this->expectedExceptionMessage = 'Oh oh, bananas in the instruments.';
\Drupal::state()
->set('error_service_test.break_bare_html_renderer', TRUE);
$settings = [];
$settings['config']['system.logging']['error_level'] = (object) [
'value' => ERROR_REPORTING_HIDE,
'required' => TRUE,
];
$this
->writeSettings($settings);
$this
->drupalGet('');
$this
->assertSession()
->statusCodeEquals(500);
$this
->assertSession()
->pageTextContains('The website encountered an unexpected error. Please try again later.');
$this
->assertSession()
->pageTextNotContains($this->expectedExceptionMessage);
$settings = [];
$settings['config']['system.logging']['error_level'] = (object) [
'value' => ERROR_REPORTING_DISPLAY_ALL,
'required' => TRUE,
];
$this
->writeSettings($settings);
$this
->drupalGet('');
$this
->assertSession()
->statusCodeEquals(500);
$this
->assertSession()
->pageTextContains('The website encountered an unexpected error. Please try again later.');
$this
->assertSession()
->pageTextContains($this->expectedExceptionMessage);
$this
->assertErrorLogged($this->expectedExceptionMessage);
}