You are here

public function UncaughtExceptionTest::testMissingDependency in Drupal 8

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

Tests a missing dependency on a service.

File

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

Class

UncaughtExceptionTest
Tests kernel panic when things are really messed up.

Namespace

Drupal\FunctionalTests\Bootstrap

Code

public function testMissingDependency() {
  if (version_compare(PHP_VERSION, '7.1') < 0) {
    $this->expectedExceptionMessage = 'Argument 1 passed to Drupal\\error_service_test\\LonelyMonkeyClass::__construct() must be an instance of Drupal\\Core\\Database\\Connection, non';
  }
  else {
    $this->expectedExceptionMessage = 'Too few arguments to function Drupal\\error_service_test\\LonelyMonkeyClass::__construct(), 0 passed';
  }
  $this
    ->drupalGet('broken-service-class');
  $this
    ->assertResponse(500);
  $this
    ->assertRaw('The website encountered an unexpected error.');
  $this
    ->assertRaw($this->expectedExceptionMessage);
  $this
    ->assertErrorLogged($this->expectedExceptionMessage);
}