function EntityUnitTestBase::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/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());
}

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