function ServicesDefaultsTest::testAutowiring
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/DependencyInjection/ServicesDefaultsTest.php \Drupal\KernelTests\Core\DependencyInjection\ServicesDefaultsTest::testAutowiring()
- 11.x core/tests/Drupal/KernelTests/Core/DependencyInjection/ServicesDefaultsTest.php \Drupal\KernelTests\Core\DependencyInjection\ServicesDefaultsTest::testAutowiring()
Tests that 'services_defaults_test.service' has its dependencies injected.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ DependencyInjection/ ServicesDefaultsTest.php, line 20
Class
- ServicesDefaultsTest
- Tests services _defaults definition.
Namespace
Drupal\KernelTests\Core\DependencyInjectionCode
public function testAutowiring() {
// Ensure interface autowiring works.
$this->assertSame($this->container
->get('Drupal\\services_defaults_test\\TestInjection'), $this->container
->get('Drupal\\services_defaults_test\\TestService')
->getTestInjection());
// Ensure defaults autowire works.
$this->assertSame($this->container
->get('Drupal\\services_defaults_test\\TestInjection2'), $this->container
->get('Drupal\\services_defaults_test\\TestService')
->getTestInjection2());
// Ensure that disabling autowiring works.
$this->assertNotSame($this->container
->get('Drupal\\services_defaults_test\\TestInjection'), $this->container
->get('services_default_test.no_autowire')
->getTestInjection());
$this->assertSame($this->container
->get('services_default_test.no_autowire.arg'), $this->container
->get('services_default_test.no_autowire')
->getTestInjection());
$this->assertSame($this->container
->get('Drupal\\services_defaults_test\\TestInjection2'), $this->container
->get('services_default_test.no_autowire')
->getTestInjection2());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.