Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::registerTest()
  2. 9 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 141

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');

  // Add the wait terminate middleware which acquires a lock to signal request
  // termination to the test runner.
  $container
    ->register('test.http_middleware.wait_terminate_middleware', 'Drupal\\Core\\Test\\StackMiddleware\\TestWaitTerminateMiddleware')
    ->setArguments([
    new Reference('state'),
    new Reference('lock'),
  ])
    ->addTag('http_middleware', [
    'priority' => -1024,
  ]);
}