function AutowireBlockTest::testAutowireError

Tests that autowire errors are handled correctly.

File

core/tests/Drupal/KernelTests/Core/Block/AutowireBlockTest.php, line 38

Class

AutowireBlockTest
Tests that blocks can be autowired.

Namespace

Drupal\KernelTests\Core\Block

Code

public function testAutowireError() : void {
  $this->expectException(AutowiringFailedException::class);
  $this->expectExceptionMessage('Cannot autowire service "Drupal\\Core\\Lock\\LockBackendInterface": argument "$lock" of method "Drupal\\autowire_test\\Plugin\\Block\\AutowireErrorBlock::_construct()", you should configure its value explicitly.');
  \Drupal::service('plugin.manager.block')->createInstance('autowire_error');
}

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