function ServiceProviderTest::testServiceProviderRegistration

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php \Drupal\KernelTests\Core\ServiceProvider\ServiceProviderTest::testServiceProviderRegistration()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php \Drupal\KernelTests\Core\ServiceProvider\ServiceProviderTest::testServiceProviderRegistration()
  3. 10 core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php \Drupal\KernelTests\Core\ServiceProvider\ServiceProviderTest::testServiceProviderRegistration()

Tests that services provided by module service providers get registered to the DIC.

File

core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php, line 45

Class

ServiceProviderTest
Tests service provider registration to the DIC.

Namespace

Drupal\KernelTests\Core\ServiceProvider

Code

public function testServiceProviderRegistration() : void {
    $definition = $this->container
        ->getDefinition('file.usage');
    $this->assertSame('Drupal\\service_provider_test\\TestFileUsage', $definition->getClass(), 'Class has been changed');
    $this->assertTrue(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service has been registered to the DIC');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.