You are here

protected function TestRemoteManager::doRequest in Entity Share 8.3

Performs a HTTP request.

Parameters

\GuzzleHttp\ClientInterface $client: The client which will do the request.

string $method: HTTP method.

string $url: URL to request.

Return value

\Psr\Http\Message\ResponseInterface||null The response or NULL if a problem occurred.

Overrides RemoteManager::doRequest

See also

\GuzzleHttp\ClientInterface::request()

File

modules/entity_share_client/tests/modules/entity_share_client_remote_manager_test/src/Service/TestRemoteManager.php, line 27

Class

TestRemoteManager
Service that allows to emulate another website in tests.

Namespace

Drupal\entity_share_client_remote_manager_test\Service

Code

protected function doRequest(ClientInterface $client, $method, $url) {

  // It it is a GET request store the result to be able to re-obtain the
  // result to simulate another website.
  if ($method == 'GET') {
    if (!isset($this->responseMapping[$url])) {
      $this->responseMapping[$url] = parent::doRequest($client, $method, $url);
    }
    return $this->responseMapping[$url];
  }
  return parent::doRequest($client, $method, $url);
}