You are here

protected function OEmbedTestTrait::lockHttpClientToFixtures in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Traits/OEmbedTestTrait.php \Drupal\Tests\media\Traits\OEmbedTestTrait::lockHttpClientToFixtures()
  2. 9 core/modules/media/tests/src/Traits/OEmbedTestTrait.php \Drupal\Tests\media\Traits\OEmbedTestTrait::lockHttpClientToFixtures()

Configures the http_client service so that all requests are carried out relative to the URL of the fixtures directory. For example, after calling this method, a request for foobar.html will actually request http://test-site/path/to/fuxtures/foobar.html.

1 call to OEmbedTestTrait::lockHttpClientToFixtures()
OEmbedFormatterTest::setUp in core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php

File

core/modules/media/tests/src/Traits/OEmbedTestTrait.php, line 47

Class

OEmbedTestTrait
Contains helper functions for testing oEmbed functionality in isolation.

Namespace

Drupal\Tests\media\Traits

Code

protected function lockHttpClientToFixtures() {
  $this
    ->writeSettings([
    'settings' => [
      'http_client_config' => [
        'base_uri' => (object) [
          'value' => $this
            ->getFixturesUrl() . '/',
          'required' => TRUE,
        ],
      ],
    ],
  ]);

  // Rebuild the container in case there is already an instantiated service
  // that has a dependency on the http_client service.
  $this->container
    ->get('kernel')
    ->rebuildContainer();
  $this->container = $this->container
    ->get('kernel')
    ->getContainer();
}