You are here

public function UncaughtExceptionTest::testErrorContainer in Drupal 8

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

Tests a container which has an error.

File

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

Class

UncaughtExceptionTest
Tests kernel panic when things are really messed up.

Namespace

Drupal\FunctionalTests\Bootstrap

Code

public function testErrorContainer() {
  $settings = [];
  $settings['settings']['container_base_class'] = (object) [
    'value' => '\\Drupal\\FunctionalTests\\Bootstrap\\ErrorContainer',
    'required' => TRUE,
  ];
  $this
    ->writeSettings($settings);
  \Drupal::service('kernel')
    ->invalidateContainer();
  $this->expectedExceptionMessage = 'Argument 1 passed to Drupal\\FunctionalTests\\Bootstrap\\ErrorContainer::Drupal\\FunctionalTests\\Bootstrap\\{closur';
  $this
    ->drupalGet('');
  $this
    ->assertResponse(500);
  $this
    ->assertRaw($this->expectedExceptionMessage);
  $this
    ->assertErrorLogged($this->expectedExceptionMessage);
}