class AutowireTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php \Drupal\KernelTests\Core\DependencyInjection\AutowireTest
- 10 core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php \Drupal\KernelTests\Core\DependencyInjection\AutowireTest
Tests auto-wiring services.
@group DependencyInjection
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\DependencyInjection\AutowireTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of AutowireTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ DependencyInjection/ AutowireTest.php, line 15
Namespace
Drupal\KernelTests\Core\DependencyInjectionView source
class AutowireTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'autowire_test',
];
/**
* Tests that 'autowire_test.service' has its dependencies injected.
*/
public function testAutowire() : void {
// Ensure an autowired interface works.
$this->assertInstanceOf(TestInjection::class, $this->container
->get(TestService::class)
->getTestInjection());
// Ensure an autowired class works.
$this->assertInstanceOf(TestInjection2::class, $this->container
->get(TestService::class)
->getTestInjection2());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.