function UncaughtExceptionTest::testUncaughtFatalError

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtFatalError()
  2. 10 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtFatalError()
  3. 11.x 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 111

Class

UncaughtExceptionTest
Tests kernel panic when things are really messed up.

Namespace

Drupal\FunctionalTests\Bootstrap

Code

public function testUncaughtFatalError() {
    $fatal_error = [
        '%type' => 'TypeError',
        '@message' => 'Argument 1 passed to Drupal\\error_test\\Controller\\ErrorTestController::Drupal\\error_test\\Controller\\{closure}() must be of the type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 62',
        '%function' => 'Drupal\\error_test\\Controller\\ErrorTestController->Drupal\\error_test\\Controller\\{closure}()',
    ];
    $this->drupalGet('error-test/generate-fatals');
    $this->assertResponse(500);
    $message = new FormattableMarkup('%type: @message in %function (line ', $fatal_error);
    $this->assertRaw((string) $message);
    $this->assertRaw('<pre class="backtrace">');
    // Ensure we are escaping but not double escaping.
    $this->assertRaw('&#039;');
    $this->assertNoRaw('&amp;#039;');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.