function EntityKernelTestBase::reloadEntity

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::reloadEntity()
  2. 10 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.

11 calls to EntityKernelTestBase::reloadEntity()
ContentEntityCloneTest::testClonedEntityFields in core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php
Tests if the entity fields are properly cloned.
EntityRevisionTranslationTest::testRevertRevisionAfterTranslation in core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php
Tests if the translation object has the right revision id after new revision.
EntityRevisionTranslationTest::testTranslationValuesWhenSavingPendingRevisions in core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php
Tests the translation values when saving a pending revision.
EntityTranslationTest::doTestEntityTranslationAPI in core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
Executes the Entity Translation API tests for the given entity type.
EntityTranslationTest::doTestLanguageFallback in core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
Executes the language fallback test for the given entity type.

... See full list

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.