function JsonApiFunctionalTestBase::request
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalTestBase::request()
- 10 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalTestBase::request()
- 11.x 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
30 calls to JsonApiFunctionalTestBase::request()
- JsonApiFunctionalMultilingualTest::testDeleteMultilingual in core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiFunctionalMultilingualTest.php - Tests deleting multilingual content.
- JsonApiFunctionalMultilingualTest::testPatchTranslation in core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiFunctionalMultilingualTest.php - Tests updating a translation.
- JsonApiFunctionalMultilingualTest::testPatchTranslationFallback in core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiFunctionalMultilingualTest.php - Tests updating a translation fallback.
- JsonApiFunctionalMultilingualTest::testPostTranslation in core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiFunctionalMultilingualTest.php - Tests creating a translation.
- JsonApiFunctionalTest::testRead in core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiFunctionalTest.php - Test the GET method.
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.