You are here

protected function HttpMimeTypeGuesserTest::prepareClient in Remote Stream Wrapper 8

Prepare the mock HTTP requests and responses.

Parameters

$url:

$head_response:

$get_response:

Return value

\GuzzleHttp\ClientInterface

1 call to HttpMimeTypeGuesserTest::prepareClient()
HttpMimeTypeGuesserTest::testHttpMimeTypeGuessing in tests/src/Kernel/HttpMimeTypeGuesserTest.php
Test the mime type guessing with various HTTP URLs.

File

tests/src/Kernel/HttpMimeTypeGuesserTest.php, line 151

Class

HttpMimeTypeGuesserTest
@coversDefaultClass \Drupal\remote_stream_wrapper\File\MimeType\HttpMimeTypeGuesser @group remote_stream_wrapper

Namespace

Drupal\Tests\remote_stream_wrapper\Kernel

Code

protected function prepareClient($url, $head_response, $get_response) {
  $client = $this
    ->prophesize('\\GuzzleHttp\\Client');
  if ($head_response instanceof Response) {
    $client
      ->request('HEAD', $url, [])
      ->willReturn($head_response);
  }
  elseif ($head_response instanceof \Exception) {
    $client
      ->request('HEAD', $url, [])
      ->willThrow($head_response);
  }
  if ($get_response instanceof Response) {
    $client
      ->request('GET', $url, [])
      ->willReturn($get_response);
  }
  elseif ($get_response instanceof \Exception) {
    $client
      ->request('GET', $url, [])
      ->willThrow($get_response);
  }
  return $client
    ->reveal();
}