$entity_collection =
$this->
getData();
assert(count($entity_collection) > 1, 'A collection must have more that one entity in it.'
);
$collection_url = Url::
fromRoute(sprintf('jsonapi.%s.collection',
static::
$resourceTypeName))->
setAbsolute(TRUE
);
$request_options =
[];
$request_options[RequestOptions::HEADERS
]['Accept'
] = 'application/vnd.api+json';
$request_options = NestedArray::
mergeDeep($request_options,
$this->
getAuthenticationRequestOptions());
// This asserts that collections will work without a sort, added by default
// below, without actually asserting the content of the response.
$expected_response =
$this->
getExpectedCollectionResponse($entity_collection,
$collection_url->
toString(),
$request_options);
$expected_cacheability =
$expected_response->
getCacheableMetadata();
$response =
$this->
request('HEAD',
$collection_url,
$request_options);
// MISS or UNCACHEABLE depends on the collection data. It must not be HIT.
$dynamic_cache =
$expected_cacheability->
getCacheMaxAge() === 0 ? 'UNCACHEABLE' : 'MISS';
$this->
assertResourceResponse(200, NULL,
$response,
$expected_cacheability->
getCacheTags(),
$expected_cacheability->
getCacheContexts(), FALSE,
$dynamic_cache);
// Different databases have different sort orders, so a sort is required so
// test expectations do not need to vary per database.
$default_sort =
['sort' => 'drupal_internal__' .
$this->entity->
getEntityType()->
getKey('id'
)];
$collection_url->
setOption('query',
$default_sort);
// 200 for collections, even when all entities are inaccessible. Access is