$detail = 'The current user is not allowed to GET the selected resource. The user does not have access to the requested version.';
$message =
$result instanceof AccessResultReasonInterface ?
trim($detail . ' ' .
$result->
getReason()) :
$detail;
$this->
assertResourceErrorResponse(403,
$message,
$url,
$actual_response, '/data',
$expected_cache_tags,
$expected_cache_contexts, FALSE, 'MISS'
);
// On the collection URL, we should expect to see the draft omitted from
// the collection.
$actual_response =
$this->
request('GET',
$rel_working_copy_collection_url,
$request_options);
$expected_response =
static::
getExpectedCollectionResponse([$entity],
$rel_working_copy_collection_url->
toString(),
$request_options);
$expected_collection_document =
$expected_response->
getResponseData();
$expected_collection_document['data'
] =
[];
$expected_cacheability =
$expected_response->
getCacheableMetadata();
$access_denied_response =
static::
getAccessDeniedResponse($entity,
$result,
$url, NULL,
$detail)->
getResponseData();
static::
addOmittedObject($expected_collection_document,
static::
errorsToOmittedObject($access_denied_response['errors'
]));
$this->
assertResourceResponse(200,
$expected_collection_document,
$actual_response,
$expected_cacheability->
getCacheTags(),
$expected_cacheability->
getCacheContexts(), FALSE, 'MISS'
);
} // Since additional permissions are required to see 'draft' entities,
// grant those permissions.
$this->
grantPermissionsToTestedRole($this->
getEditorialPermissions());
// Now, the `working-copy` link should be latest revision and be accessible.
$actual_response =
$this->
request('GET',
$rel_working_copy_url,
$request_options);
$expected_document['data'
]['attributes'
][$revision_id_key] =
$forward_revision_id;
$expected_document['data'
]['attributes'
]['moderation_state'
] = 'draft';