function ServiceProviderTest::register

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php \Drupal\KernelTests\Core\ServiceProvider\ServiceProviderTest::register()

Overrides KernelTestBase::register

File

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

Class

ServiceProviderTest
Tests service provider registration to the DIC.

Namespace

Drupal\KernelTests\Core\ServiceProvider

Code

public function register(ContainerBuilder $container) {
    parent::register($container);
    // Undo cache_factory override done in parent because it can hide caching
    // issues in container build time.
    // @see \Drupal\service_provider_test\ServiceProviderTestServiceProvider::alter()
    $this->container
        ->register('cache_factory', CacheFactory::class)
        ->addArgument(new Reference('settings'))
        ->addArgument(new Parameter('cache_default_bin_backends'))
        ->addMethodCall('setContainer', [
        new Reference('service_container'),
    ]);
}

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