You are here

protected function LayoutRestTestBase::request in Layout Builder Symmetric Translations 8

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

Overrides ResourceTestBase::request

See also

\GuzzleHttp\ClientInterface::request()

1 call to LayoutRestTestBase::request()
OverrideSectionsTest::testOverrideField in tests/src/Functional/Rest/OverrideSectionsTest.php
Tests that the layout override field is not normalized.

File

tests/src/Functional/Rest/LayoutRestTestBase.php, line 102

Class

LayoutRestTestBase
Base class for Layout Builder REST tests.

Namespace

Drupal\Tests\layout_builder_st\Functional\Rest

Code

protected function request($method, Url $url, array $request_options = []) {
  $request_options[RequestOptions::HEADERS] = [
    'Content-Type' => static::$mimeType,
  ];
  $request_options = NestedArray::mergeDeep($request_options, $this
    ->getAuthenticationRequestOptions($method));
  $request_options[RequestOptions::QUERY] = [
    '_format' => static::$format,
  ];
  return parent::request($method, $url, $request_options);
}