function CoreServiceProvider::registerTest

Same name in other branches
  1. 9 core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::registerTest()
  2. 10 core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::registerTest()
  3. 11.x core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::registerTest()

Registers services and event subscribers for a site under test.

Parameters

\Drupal\Core\DependencyInjection\ContainerBuilder $container: The container builder.

1 call to CoreServiceProvider::registerTest()
CoreServiceProvider::register in core/lib/Drupal/Core/CoreServiceProvider.php
Registers services to the container.

File

core/lib/Drupal/Core/CoreServiceProvider.php, line 181

Class

CoreServiceProvider
ServiceProvider class for mandatory core services.

Namespace

Drupal\Core

Code

protected function registerTest(ContainerBuilder $container) {
    // Do nothing if we are not in a test environment.
    if (!drupal_valid_test_ua()) {
        return;
    }
    // The test middleware is not required for kernel tests as there is no child
    // site. DRUPAL_TEST_IN_CHILD_SITE is not defined in this case.
    if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) {
        return;
    }
    // Add the HTTP request middleware to Guzzle.
    $container->register('test.http_client.middleware', 'Drupal\\Core\\Test\\HttpClientMiddleware\\TestHttpClientMiddleware')
        ->addTag('http_client_middleware');
}

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