You are here

protected function ResourceResponseTestTrait::getResponses in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::getResponses()

Gets responses from an array of links.

Parameters

array $links: A keyed array of links.

array $request_options: Request options to apply.

Return value

array The fetched array of responses, keys are preserved.

See also

\GuzzleHttp\ClientInterface::request()

5 calls to ResourceResponseTestTrait::getResponses()
ResourceResponseTestTrait::getExpectedIncludedResourceResponse in tests/src/Functional/ResourceResponseTestTrait.php
Gets an array of expected ResourceResponses for the given include paths.
ResourceResponseTestTrait::getRelatedResponses in tests/src/Functional/ResourceResponseTestTrait.php
Gets an array of related responses for the given field names.
ResourceResponseTestTrait::getRelationshipResponses in tests/src/Functional/ResourceResponseTestTrait.php
Gets an array of relationship responses for the given field names.
ResourceTestBase::getExpectedCollectionResponse in tests/src/Functional/ResourceTestBase.php
Returns a JSON API collection document for the expected entities.
ResourceTestBase::getExpectedRelatedResponses in tests/src/Functional/ResourceTestBase.php
Builds an array of expected related ResourceResponses, keyed by field name.

File

tests/src/Functional/ResourceResponseTestTrait.php, line 446

Class

ResourceResponseTestTrait
Utility methods for handling resource responses.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getResponses(array $links, array $request_options) {
  return array_reduce(array_keys($links), function ($related_responses, $key) use ($links, $request_options) {
    $related_responses[$key] = $this
      ->request('GET', Url::fromUri($links[$key]), $request_options);
    return $related_responses;
  }, []);
}