function ServiceProviderTest::testServiceProviderRegistrationDynamic
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php \Drupal\KernelTests\Core\ServiceProvider\ServiceProviderTest::testServiceProviderRegistrationDynamic()
- 8.9.x core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php \Drupal\KernelTests\Core\ServiceProvider\ServiceProviderTest::testServiceProviderRegistrationDynamic()
- 10 core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php \Drupal\KernelTests\Core\ServiceProvider\ServiceProviderTest::testServiceProviderRegistrationDynamic()
Tests that the DIC keeps up with module enable/disable in the same request.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ ServiceProvider/ ServiceProviderTest.php, line 52
Class
- ServiceProviderTest
- Tests service provider registration to the DIC.
Namespace
Drupal\KernelTests\Core\ServiceProviderCode
public function testServiceProviderRegistrationDynamic() : void {
// Uninstall the module and ensure the service provider's service is not registered.
\Drupal::service('module_installer')->uninstall([
'service_provider_test',
]);
$this->assertFalse(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service does not exist in the DIC.');
// Install the module and ensure the service provider's service is registered.
\Drupal::service('module_installer')->install([
'service_provider_test',
]);
$this->assertTrue(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service exists in the DIC.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.