You are here

public function UncaughtExceptionTest::testExceptionContainer in Drupal 8

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

Tests a container which has an exception really early.

File

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

Class

UncaughtExceptionTest
Tests kernel panic when things are really messed up.

Namespace

Drupal\FunctionalTests\Bootstrap

Code

public function testExceptionContainer() {
  $settings = [];
  $settings['settings']['container_base_class'] = (object) [
    'value' => '\\Drupal\\FunctionalTests\\Bootstrap\\ExceptionContainer',
    'required' => TRUE,
  ];
  $this
    ->writeSettings($settings);
  \Drupal::service('kernel')
    ->invalidateContainer();
  $this->expectedExceptionMessage = 'Thrown exception during Container::get';
  $this
    ->drupalGet('');
  $this
    ->assertResponse(500);
  $this
    ->assertRaw('The website encountered an unexpected error');
  $this
    ->assertRaw($this->expectedExceptionMessage);
  $this
    ->assertErrorLogged($this->expectedExceptionMessage);
}