if ($this->entity instanceof ConfigEntityInterface
) { $this->
markTestSkipped('PATCHing config entities is not yet supported.'
);
} $prior_revision_id =
(int) $this->
entityLoadUnchanged($this->entity->
id())->
getRevisionId();
// Patch testing requires that another entity of the same type exists.
$this->anotherEntity =
$this->
createAnotherEntity('dupe'
);
// Try with all of the following request bodies.
$unparseable_request_body = '!{>}<';
$parseable_valid_request_body = Json::
encode($this->
getPatchDocument());
if ($this->entity->
getEntityType()->
hasKey('label'
)) { $parseable_invalid_request_body = Json::
encode($this->
makeNormalizationInvalid($this->
getPatchDocument(), 'label'
));
} $parseable_invalid_request_body_2 = Json::
encode(NestedArray::
mergeDeep(['data' =>
['attributes' =>
['field_rest_test' =>
$this->
randomString()]]],
$this->
getPatchDocument()));
// The 'field_rest_test' field does not allow 'view' access, so does not end
// up in the JSON:API document. Even when we explicitly add it to the JSON
// API document that we send in a PATCH request, it is considered invalid.
$parseable_invalid_request_body_3 = Json::
encode(NestedArray::
mergeDeep(['data' =>
['attributes' =>
['field_rest_test' =>
$this->entity->
get('field_rest_test'
)->
getValue()]]],
$this->
getPatchDocument()));
$parseable_invalid_request_body_4 = Json::
encode(NestedArray::
mergeDeep(['data' =>
['attributes' =>
['field_nonexistent' =>
$this->
randomString()]]],
$this->
getPatchDocument()));
// It is invalid to PATCH a relationship field under the attributes member.
if ($this->entity instanceof FieldableEntityInterface &&
$this->entity->
hasField('field_jsonapi_test_entity_ref'
)) {