You are here

protected function OEmbedTestTrait::lockHttpClientToFixtures in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Traits/OEmbedTestTrait.php \Drupal\Tests\media\Traits\OEmbedTestTrait::lockHttpClientToFixtures()
  2. 10 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.

6 calls to OEmbedTestTrait::lockHttpClientToFixtures()
MediaSourceOEmbedVideoTest::setUp in core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
MediaStandardProfileTest::setUp in core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php
OEmbedFormatterTest::setUp in core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php
ResourceFetcherTest::setUp in core/modules/media/tests/src/Functional/ResourceFetcherTest.php
UrlResolverTest::setUp in core/modules/media/tests/src/Functional/UrlResolverTest.php

... See full list

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();
}