protected function JsonApiFunctionalTestBase::request in JSON:API 8
Same name and namespace in other branches
- 8.2 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
8 calls to JsonApiFunctionalTestBase::request()
- JsonApiFunctionalTest::testRead in tests/
src/ Functional/ JsonApiFunctionalTest.php - Test the GET method.
- JsonApiFunctionalTest::testWrite in tests/
src/ Functional/ JsonApiFunctionalTest.php - Test POST, PATCH and DELETE.
- JsonApiRegressionTest::testBundlelessRelationshipMutationFromIssue2973681 in tests/
src/ Functional/ JsonApiRegressionTest.php - Ensure POST and PATCH works for bundle-less relationship routes.
- JsonApiRegressionTest::testBundleSpecificTargetEntityTypeFromIssue2953207 in tests/
src/ Functional/ JsonApiRegressionTest.php - Ensure filtering on relationships works with bundle-specific target types.
- JsonApiRegressionTest::testDanglingReferencesInAnEntityReferenceFieldFromIssue2968972 in tests/
src/ Functional/ JsonApiRegressionTest.php - Cannot PATCH an entity with dangling references in an ER field.
File
- tests/
src/ Functional/ JsonApiFunctionalTestBase.php, line 210
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;
}