// Create an account, which tests will use. Also ensure the @current_user
// service this account, to ensure certain access check logic in tests works
// as expected.
$this->account =
$this->
createUser();
$this->container->
get('current_user'
)->
setAccount($this->account
);
// Create an entity.
$entity_type_manager =
$this->container->
get('entity_type.manager'
);
$this->entityStorage =
$entity_type_manager->
getStorage(static::
$entityTypeId);
$this->uuidKey =
$entity_type_manager->
getDefinition(static::
$entityTypeId) ->
getKey('uuid'
);
$this->entity =
$this->
setUpFields($this->
createEntity(),
$this->account
);
$this->resourceType =
$this->container->
get('jsonapi.resource_type.repository'
)->
getByTypeName(static::
$resourceTypeName);
} /**
* Sets up additional fields for testing.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The primary test entity.
* @param \Drupal\user\UserInterface $account
* The primary test user account.
*
* @return \Drupal\Core\Entity\EntityInterface
* The reloaded entity with the new fields attached.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/