function 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 127

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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.