You are here

protected function UncaughtExceptionTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::setUp()
  2. 9 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::setUp()

Overrides BrowserTestBase::setUp

File

core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php, line 37

Class

UncaughtExceptionTest
Tests kernel panic when things are really messed up.

Namespace

Drupal\FunctionalTests\Bootstrap

Code

protected function setUp() : void {
  parent::setUp();
  $settings_filename = $this->siteDirectory . '/settings.php';
  chmod($settings_filename, 0777);
  $settings_php = file_get_contents($settings_filename);
  $settings_php .= "\ninclude_once 'core/tests/Drupal/FunctionalTests/Bootstrap/ErrorContainer.php';\n";
  $settings_php .= "\ninclude_once 'core/tests/Drupal/FunctionalTests/Bootstrap/ExceptionContainer.php';\n";

  // Ensure we can test errors rather than being caught in
  // \Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware.
  $settings_php .= "\ndefine('SIMPLETEST_COLLECT_ERRORS', FALSE);\n";
  file_put_contents($settings_filename, $settings_php);
  $settings = [];
  $settings['config']['system.logging']['error_level'] = (object) [
    'value' => ERROR_REPORTING_DISPLAY_VERBOSE,
    'required' => TRUE,
  ];
  $this
    ->writeSettings($settings);
}