You are here

protected function EntityUnitTestBase::reloadEntity in Drupal 8

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/modules/system/src/Tests/Entity/EntityUnitTestBase.php, line 138

Class

EntityUnitTestBase
Defines an abstract test base for entity unit tests.

Namespace

Drupal\system\Tests\Entity

Code

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