protected function JsonApiFunctionalTestBase::request in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalTestBase::request()
- 9 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalTestBase::request()
Performs a HTTP request. Wraps the Guzzle HTTP client.
Why wrap the Guzzle HTTP client? Because any error response is returned via an exception, which would make the tests unnecessarily complex to read.
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 request response.
Throws
\GuzzleHttp\Exception\GuzzleException
See also
\GuzzleHttp\ClientInterface::request
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiFunctionalTestBase.php, line 217
Class
- JsonApiFunctionalTestBase
- Provides helper methods for the JSON:API module's functional tests.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function request($method, Url $url, array $request_options) {
try {
$response = $this->httpClient
->request($method, $url
->toString(), $request_options);
} catch (ClientException $e) {
$response = $e
->getResponse();
} catch (ServerException $e) {
$response = $e
->getResponse();
}
return $response;
}