$uuid =
$second_created_entity->
uuid();
// @todo Remove line below in favor of commented line in https://www.drupal.org/project/drupal/issues/2878463.
$location = Url::
fromRoute(sprintf('jsonapi.%s.individual',
static::
$resourceTypeName),
['entity' =>
$uuid]);
/* $location = $this->entityStorage->load(static::$secondCreatedEntityId)->toUrl('jsonapi')->setAbsolute(TRUE)->toString(); */
if (static::
$resourceTypeIsVersionable) { assert($created_entity instanceof RevisionableInterface
);
$location->
setOption('query',
['resourceVersion' => 'id:' .
$second_created_entity->
getRevisionId()]);
} $this->
assertSame([$location->
setAbsolute()->
toString()],
$response->
getHeader('Location'
));
// 500 when creating an entity with a duplicate UUID.
$doc =
$this->
getModifiedEntityForPostTesting();
$doc['data'
]['id'
] =
$uuid;
$label_field =
$this->entity->
getEntityType()->
hasKey('label'
) ?
$this->entity->
getEntityType()->
getKey('label'
) :
static::
$labelFieldName;
if (isset($label_field)) { $doc['data'
]['attributes'
][$label_field] =
[['value' =>
$this->
randomMachineName()]];
} $request_options[RequestOptions::BODY
] = Json::
encode($doc);
$response =
$this->
request('POST',
$url,
$request_options);
$this->
assertResourceErrorResponse(409, 'Conflict: Entity already exists.',
$url,
$response, FALSE
);
// 201 when successfully creating an entity with a new UUID.