function UncaughtExceptionTest::testUncaughtExceptionCustomExceptionHandler
Same name in other branches
- 9 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtExceptionCustomExceptionHandler()
- 8.9.x core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtExceptionCustomExceptionHandler()
- 11.x core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtExceptionCustomExceptionHandler()
Tests uncaught exception handling with custom exception handler.
File
-
core/
tests/ Drupal/ FunctionalTests/ Bootstrap/ UncaughtExceptionTest.php, line 114
Class
- UncaughtExceptionTest
- Tests kernel panic when things are really messed up.
Namespace
Drupal\FunctionalTests\BootstrapCode
public function testUncaughtExceptionCustomExceptionHandler() : void {
$settings_filename = $this->siteDirectory . '/settings.php';
chmod($settings_filename, 0777);
$settings_php = file_get_contents($settings_filename);
$settings_php .= "\n";
$settings_php .= "set_exception_handler(function() {\n";
$settings_php .= " header('HTTP/1.1 418 I\\'m a teapot');\n";
$settings_php .= " print('Oh oh, flying teapots');\n";
$settings_php .= "});\n";
file_put_contents($settings_filename, $settings_php);
\Drupal::state()->set('error_service_test.break_bare_html_renderer', TRUE);
$this->drupalGet('');
$this->assertSession()
->statusCodeEquals(418);
$this->assertSession()
->pageTextNotContains('The website encountered an unexpected error. Try again later.');
$this->assertSession()
->pageTextNotContains('Oh oh, bananas in the instruments');
$this->assertSession()
->pageTextContains('Oh oh, flying teapots');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.