You are here

trait EntityShareServerRequestTestTrait in Entity Share 8.2

Same name and namespace in other branches
  1. 8.3 modules/entity_share_server/tests/src/Functional/EntityShareServerRequestTestTrait.php \Drupal\Tests\entity_share_server\Functional\EntityShareServerRequestTestTrait

Boilerplate for Entity share server Functional tests' HTTP requests.

Hierarchy

1 file declares its use of EntityShareServerRequestTestTrait
EntityShareClientFunctionalTestBase.php in modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php

File

modules/entity_share_server/tests/src/Functional/EntityShareServerRequestTestTrait.php, line 14

Namespace

Drupal\Tests\entity_share_server\Functional
View source
trait EntityShareServerRequestTestTrait {
  use JsonApiRequestTestTrait {
    JsonApiRequestTestTrait::request as parentRequest;
  }

  /**
   * Performs a HTTP request. Wraps the Guzzle HTTP client.
   *
   * Why wrap the Guzzle HTTP client? Because we want to keep the actual test
   * code as simple as possible, and hence not require them to specify the
   * 'http_errors = FALSE' request option, nor do we want them to have to
   * convert Drupal Url objects to strings.
   *
   * We also don't want to follow redirects automatically, to ensure these tests
   * are able to detect when redirects are added or removed.
   *
   * @param string $method
   *   HTTP method.
   * @param \Drupal\Core\Url $url
   *   URL to request.
   * @param array $request_options
   *   Request options to apply.
   *
   * @return \Psr\Http\Message\ResponseInterface
   *   The response.
   *
   * @see \GuzzleHttp\ClientInterface::request()
   */
  protected function request($method, Url $url, array $request_options) {
    if (!isset($request_options[RequestOptions::HEADERS])) {
      $request_options[RequestOptions::HEADERS] = [];
    }
    $request_options[RequestOptions::HEADERS]['Content-Type'] = 'application/vnd.api+json';
    return $this
      ->parentRequest($method, $url, $request_options);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityShareServerRequestTestTrait::request protected function Performs a HTTP request. Wraps the Guzzle HTTP client.
JsonApiRequestTestTrait::decorateWithXdebugCookie protected function Adds the Xdebug cookie to the request options.
JsonApiRequestTestTrait::request protected function Performs a HTTP request. Wraps the Guzzle HTTP client. Aliased as: parentRequest