function ResourceResponseTestTrait::getRelatedResponses

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

Gets an array of related responses for the given field names.

Parameters

array $relationship_field_names: The list of relationship field names for which to get responses.

array $request_options: Request options to apply.

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

Return value

array The related responses, keyed by relationship field names.

See also

\GuzzleHttp\ClientInterface::request()

1 call to ResourceResponseTestTrait::getRelatedResponses()
ResourceTestBase::doTestRelated in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Performs one round of related route testing.

File

core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php, line 435

Class

ResourceResponseTestTrait
Utility methods for handling resource responses.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getRelatedResponses(array $relationship_field_names, array $request_options, ?EntityInterface $entity = NULL) {
    $entity = $entity ?: $this->entity;
    $links = array_map(function ($relationship_field_name) use ($entity) {
        return static::getRelatedLink(static::toResourceIdentifier($entity), $relationship_field_name);
    }, array_combine($relationship_field_names, $relationship_field_names));
    return $this->getResponses($links, $request_options);
}

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