protected function LayoutRestTestBase::request in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::request()
- 10 core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::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
Overrides ResourceTestBase::request
See also
\GuzzleHttp\ClientInterface::request()
1 call to LayoutRestTestBase::request()
- OverrideSectionsTest::testOverrideField in core/
modules/ layout_builder/ tests/ src/ Functional/ Rest/ OverrideSectionsTest.php - Tests that the layout override field is not normalized.
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ Rest/ LayoutRestTestBase.php, line 97
Class
- LayoutRestTestBase
- Base class for Layout Builder REST tests.
Namespace
Drupal\Tests\layout_builder\Functional\RestCode
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);
}