function UncaughtExceptionTest::testUncaughtFatalError

Same name and namespace in other branches
  1. 11.x 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. 9 core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php \Drupal\FunctionalTests\Bootstrap\UncaughtExceptionTest::testUncaughtFatalError()
  4. 8.9.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 95

Class

UncaughtExceptionTest
Tests kernel panic when things are really messed up.

Namespace

Drupal\FunctionalTests\Bootstrap

Code

public function testUncaughtFatalError() : void {
  $this->drupalGet('error-test/generate-fatal-errors');
  $this->assertSession()
    ->statusCodeEquals(500);
  $message = '@<em class="placeholder">TypeError</em>: 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 .*core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 67 in <em class="placeholder">Drupal\\\\error_test\\\\Controller\\\\ErrorTestController-&gt;{closure:Drupal\\\\error_test\\\\Controller\\\\ErrorTestController::generateFatalErrors\\(\\):64}\\(\\)</em>@';
  $this->drupalGet('error-test/generate-fatal-errors');
  $this->assertSession()
    ->responseMatches($message);
  $this->assertSession()
    ->responseContains('<pre class="backtrace">');
  // Ensure we are escaping but not double escaping.
  $this->assertSession()
    ->responseContains('&gt;');
  $this->assertSession()
    ->responseNotContains('&amp;gt;');
}

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