function JsonApiFunctionalTestBase::request

Same name in other branches
  1. 8.9.x core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalTestBase::request()
  2. 10 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalTestBase::request()
  3. 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

33 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
Tests the GET method.

... See full list

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\Functional

Code

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.