You are here

public function AdvisoriesTestHttpClient::get in Drupal 9

File

core/modules/system/tests/modules/advisory_feed_test/src/AdvisoriesTestHttpClient.php, line 33

Class

AdvisoriesTestHttpClient
Provides a decorator service for the 'http_client' service for testing.

Namespace

Drupal\advisory_feed_test

Code

public function get($uri, array $options = []) : ResponseInterface {
  $test_end_point = \Drupal::state()
    ->get('advisories_test_endpoint');
  if ($test_end_point && strpos($uri, '://updates.drupal.org/psa.json') !== FALSE) {

    // Only override $uri if it matches the advisories JSON feed to avoid
    // changing any other uses of the 'http_client' service during tests with
    // this module installed.
    $uri = $test_end_point;
  }
  return $this->innerClient
    ->get($uri, $options);
}