function AutowiredInstanceTraitTest::testAutowireMissingRequiredParameter
Same name and namespace in other branches
- main core/tests/Drupal/Tests/Core/DependencyInjection/AutowiredInstanceTraitTest.php \Drupal\Tests\Core\DependencyInjection\AutowiredInstanceTraitTest::testAutowireMissingRequiredParameter()
Tests exception for missing required parameter.
File
-
core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ AutowiredInstanceTraitTest.php, line 81
Class
Namespace
Drupal\Tests\Core\DependencyInjectionCode
public function testAutowireMissingRequiredParameter() : void {
$container = $this->createStub(ContainerInterface::class);
$container->method('hasParameter')
->willReturn(FALSE);
$this->expectException(AutowiringFailedException::class);
$this->expectExceptionMessage('Cannot autowire parameter "missing.parameter": argument "$parameter" of method "Drupal\\Tests\\Core\\DependencyInjection\\AutowireRequiredParameterTestClass::__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.');
AutowireRequiredParameterTestClass::createInstanceAutowired($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.