function ControllerBaseTest::testCreateException

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Controller/ControllerBaseTest.php \Drupal\KernelTests\Core\Controller\ControllerBaseTest::testCreateException()
  2. 10 core/tests/Drupal/KernelTests/Core/Controller/ControllerBaseTest.php \Drupal\KernelTests\Core\Controller\ControllerBaseTest::testCreateException()

Tests create exception.

File

core/tests/Drupal/KernelTests/Core/Controller/ControllerBaseTest.php, line 55

Class

ControllerBaseTest
Tests \Drupal\Core\Controller\ControllerBase.

Namespace

Drupal\KernelTests\Core\Controller

Code

public function testCreateException() : void {
  $this->expectException(AutowiringFailedException::class);
  $this->expectExceptionMessage('Cannot autowire service "Drupal\\Core\\Lock\\LockBackendInterface": argument "$lock" of method "Drupal\\system_test\\Controller\\BrokenSystemTestController::__construct()". Check that either the argument type is correct or the Autowire attribute is passed a valid identifier. Otherwise configure its value explicitly if possible.');
  $this->container
    ->get('class_resolver')
    ->getInstanceFromDefinition(BrokenSystemTestController::class);
}

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