You are here

protected function ContentModerationStateTest::reloadEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::reloadEntity()

Reloads the entity after clearing the static cache.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to reload.

int|bool $revision_id: The specific revision ID to load. Defaults FALSE and just loads the default revision.

Return value

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

6 calls to ContentModerationStateTest::reloadEntity()
ContentModerationStateTest::assertDefaultRevision in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
Checks the default revision ID and publishing status for an entity.
ContentModerationStateTest::testBasicModeration in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
Tests basic monolingual content moderation through the API.
ContentModerationStateTest::testContentModerationStateDataRemoval in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
Tests removal of content moderation state entity.
ContentModerationStateTest::testContentModerationStateRevisionDataRemoval in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
Tests removal of content moderation state entity revisions.
ContentModerationStateTest::testExistingContentModerationStateDataRemoval in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
Tests removal of content moderation state entities for preexisting content.

... See full list

File

core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php, line 761

Class

ContentModerationStateTest
Tests links between a content entity and a content_moderation_state entity.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

protected function reloadEntity(EntityInterface $entity, $revision_id = FALSE) {
  $storage = \Drupal::entityTypeManager()
    ->getStorage($entity
    ->getEntityTypeId());
  $storage
    ->resetCache([
    $entity
      ->id(),
  ]);
  if ($revision_id) {
    return $storage
      ->loadRevision($revision_id);
  }
  return $storage
    ->load($entity
    ->id());
}