/**
* Tests a PATCH request for an entity, plus edge cases to ensure good DX.
*/
public function testPatch() { // @todo Remove this in https://www.drupal.org/node/2300677.
if ($this->entity instanceof ConfigEntityInterface
) { $this->
markTestSkipped('PATCHing config entities is not yet supported.'
);
} // Patch testing requires that another entity of the same type exists.
$this->anotherEntity =
$this->
createAnotherEntity();
$this->
initAuthentication();
$has_canonical_url =
$this->entity->
hasLinkTemplate('canonical'
);
// Try with all of the following request bodies.
$unparseable_request_body = '!{>}<';
$parseable_valid_request_body =
$this->serializer->
encode($this->
getNormalizedPatchEntity(),
static::
$format);
$parseable_invalid_request_body =
$this->serializer->
encode($this->
makeNormalizationInvalid($this->
getNormalizedPatchEntity(), 'label'
),
static::
$format);
$parseable_invalid_request_body_2 =
$this->serializer->
encode($this->
getNormalizedPatchEntity() +
['field_rest_test' =>
[['value' =>
$this->
randomString()]]],
static::
$format);
// The 'field_rest_test' field does not allow 'view' access, so does not end
// up in the normalization. Even when we explicitly add it the normalization