function JsonApiFunctionalTestBase::request

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

\Psr\Http\Client\ClientExceptionInterface

See also

\GuzzleHttp\ClientInterface::request

33 calls to JsonApiFunctionalTestBase::request()
JsonApiFilterRegressionTest::testBundleSpecificTargetEntityTypeFromIssue2953207 in core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php
Ensure filtering on relationships works with bundle-specific target types.
JsonApiFilterRegressionTest::testEmptyRelationshipFilteringFromIssue3025372 in core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php
Ensure filtering for entities with empty entity reference fields works.
JsonApiFilterRegressionTest::testFilterByIdFromIssue3015759 in core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php
Ensures that filtering by a sequential internal ID named 'id' is possible.
JsonApiFilterRegressionTest::testFilteringEntitiesByEntityReferenceTargetId in core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php
Tests that collections can be filtered by an entity reference target_id.
JsonApiFunctionalMultilingualTest::testDeleteMultilingual in core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalMultilingualTest.php
Tests deleting multilingual content.

... See full list

File

core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php, line 221

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.