function MediaSourceValidationTest::mockClient

Gets mock client.

Parameters

array $requestHistory: History container.

\GuzzleHttp\Psr7\Response|\Exception ...$responses: Responses.

Return value

\GuzzleHttp\ClientInterface Mock client

1 call to MediaSourceValidationTest::mockClient()
MediaSourceValidationTest::testValidation in core/modules/media/tests/src/Kernel/MediaSourceValidationTest.php
Tests existing validation constraints are respected by Media::validate.

File

core/modules/media/tests/src/Kernel/MediaSourceValidationTest.php, line 86

Class

MediaSourceValidationTest
Tests media validation.

Namespace

Drupal\Tests\media\Kernel

Code

protected function mockClient(array &$requestHistory, Response|\Exception ...$responses) : ClientInterface {
  $mock = new MockHandler(\array_values($responses));
  $handler_stack = HandlerStack::create($mock);
  $history = Middleware::history($requestHistory);
  $handler_stack->push($history);
  return new Client([
    'handler' => $handler_stack,
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.