You are here

public function AutowireTest::testAutowire in Drupal 9

Tests that 'autowire_test.service' has its dependencies injected.

File

core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php, line 25

Class

AutowireTest
Tests auto-wiring services.

Namespace

Drupal\KernelTests\Core\DependencyInjection

Code

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());
}