function ResourceTestBase::getExpectedRelatedResponses

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedRelatedResponses()
  2. 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedRelatedResponses()
  3. 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedRelatedResponses()

Builds an array of expected related ResourceResponses, keyed by field name.

Parameters

array $relationship_field_names: The relationship field names for which to build expected ResourceResponses.

array $request_options: Request options to apply.

\Drupal\Core\Entity\EntityInterface|null $entity: (optional) The entity for which to get expected related resources.

Return value

\Drupal\jsonapi\ResourceResponse[] An array of expected ResourceResponses, keyed by their relationship field name.

See also

\GuzzleHttp\ClientInterface::request()

2 calls to ResourceTestBase::getExpectedRelatedResponses()
ResourceTestBase::doTestRelated in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Performs one round of related route testing.
ResourceTestBase::getExpectedCollectionResponse in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Returns a JSON:API collection document for the expected entities.

File

core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php, line 1866

Class

ResourceTestBase
Subclass this for every JSON:API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedRelatedResponses(array $relationship_field_names, array $request_options, ?EntityInterface $entity = NULL) {
    $entity = $entity ?: $this->entity;
    return array_map(function ($relationship_field_name) use ($entity, $request_options) {
        return $this->getExpectedRelatedResponse($relationship_field_name, $request_options, $entity);
    }, array_combine($relationship_field_names, $relationship_field_names));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.