You are here

protected function EntityShareServerRequestTestTrait::request in Entity Share 8.3

Same name and namespace in other branches
  1. 8.2 modules/entity_share_server/tests/src/Functional/EntityShareServerRequestTestTrait.php \Drupal\Tests\entity_share_server\Functional\EntityShareServerRequestTestTrait::request()

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.

Parameters

string $method: HTTP method.

\Drupal\Core\Url $url: URL to request.

array $request_options: Request options to apply.

Return value

\Psr\Http\Message\ResponseInterface The response.

See also

\GuzzleHttp\ClientInterface::request()

4 calls to EntityShareServerRequestTestTrait::request()
EntityShareServerFunctionalTest::checkEntitiesOnChannel in modules/entity_share_server/tests/src/Functional/EntityShareServerFunctionalTest.php
Helper function to check the presence of entities on a specific channel.
EntityShareServerFunctionalTest::checkEntitiesOrderOnChannel in modules/entity_share_server/tests/src/Functional/EntityShareServerFunctionalTest.php
Helper function to check the order of entities on a specific channel.
EntityShareServerFunctionalTest::testBasicChannel in modules/entity_share_server/tests/src/Functional/EntityShareServerFunctionalTest.php
Test that a channel provides correct URLs.
EntityShareServerFunctionalTest::testSearchConfiguration in modules/entity_share_server/tests/src/Functional/EntityShareServerFunctionalTest.php
Test that a channel provides correct search configuration.

File

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

Class

EntityShareServerRequestTestTrait
Boilerplate for Entity Share Server Functional tests' HTTP requests.

Namespace

Drupal\Tests\entity_share_server\Functional

Code

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);
}