$url = Url::
fromRoute(sprintf('jsonapi.user--user.individual'
),
['entity' =>
$this->account->
uuid()]);
/* $url = $this->account->toUrl('jsonapi'); */
// Since this test must be performed by the user that is being modified,
// we must use $this->account, not $this->entity.
$request_options =
[];
$request_options[RequestOptions::HEADERS
]['Accept'
] = 'application/vnd.api+json';
$request_options[RequestOptions::HEADERS
]['Content-Type'
] = 'application/vnd.api+json';
$request_options = NestedArray::
mergeDeep($request_options,
$this->
getAuthenticationRequestOptions());
$response =
$this->
request('GET',
$url,
$request_options);
$original_normalization = Json::
decode((string) $response->
getBody());
// Test case 1: changing email.
$normalization =
$original_normalization;
$normalization['data'
]['attributes'
]['mail'
] = 'new-email@example.com';
$request_options[RequestOptions::BODY
] = Json::
encode($normalization);
// DX: 405 when read-only mode is enabled.
$response =
$this->
request('PATCH',
$url,
$request_options);
$this->
assertResourceErrorResponse(405,
sprintf("JSON:API is configured to accept only read operations. Site administrators can configure this at %s.", Url::
fromUri('base:/admin/config/services/jsonapi'
)->
setAbsolute()->
toString(TRUE
)->
getGeneratedUrl()),
$url,
$response);
$this->
assertSame(['GET'
],
$response->
getHeader('Allow'
));