You are here

protected function ResourceTestBase::getExpectedRelatedResponses in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedRelatedResponses()
  2. 9 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()

File

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

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));
}