You are here

protected function EntityKernelTestBase::reloadEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::reloadEntity()
  2. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::reloadEntity()

Reloads the given entity from the storage and returns it.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to be reloaded.

Return value

\Drupal\Core\Entity\EntityInterface The reloaded entity.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php, line 124

Class

EntityKernelTestBase
Defines an abstract test base for entity kernel tests.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function reloadEntity(EntityInterface $entity) {
  $controller = $this->entityTypeManager
    ->getStorage($entity
    ->getEntityTypeId());
  $controller
    ->resetCache([
    $entity
      ->id(),
  ]);
  return $controller
    ->load($entity
    ->id());
}