You are here

public function UncaughtExceptionTest::testExceptionContainer in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/System/UncaughtExceptionTest.php \Drupal\system\Tests\System\UncaughtExceptionTest::testExceptionContainer()

Tests a container which has an exception really early.

File

core/modules/system/src/Tests/System/UncaughtExceptionTest.php, line 189
Contains \Drupal\system\Tests\System\UncaughtExceptionTest.

Class

UncaughtExceptionTest
Tests kernel panic when things are really messed up.

Namespace

Drupal\system\Tests\System

Code

public function testExceptionContainer() {
  $settings = [];
  $settings['settings']['container_base_class'] = (object) [
    'value' => '\\Drupal\\system\\Tests\\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);
}