You are here

protected function WorkspacesContentModerationStateTest::assertDefaultRevision in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\WorkspacesContentModerationStateTest::assertDefaultRevision()
  2. 10 core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\WorkspacesContentModerationStateTest::assertDefaultRevision()

Checks the default revision ID and publishing status for an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity object.

int $revision_id: The expected revision ID.

bool|null $published: (optional) Whether to check if the entity is published or not. Defaults to TRUE.

Overrides ContentModerationStateTest::assertDefaultRevision

File

core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php, line 244

Class

WorkspacesContentModerationStateTest
Tests that Workspaces and Content Moderation work together properly.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

protected function assertDefaultRevision(EntityInterface $entity, $revision_id, $published = TRUE) {

  // In the context of a workspace, the default revision ID is always the
  // latest workspace-specific revision, so we need to adjust the expectation
  // of the parent assertion.
  $revision_id = $this->entityTypeManager
    ->getStorage($entity
    ->getEntityTypeId())
    ->load($entity
    ->id())
    ->getRevisionId();

  // Additionally, the publishing status of the default revision is not
  // relevant in a workspace, because getting an entity to a "published"
  // moderation state doesn't automatically make it the default revision, so
  // we have to disable that assertion.
  $published = NULL;
  parent::assertDefaultRevision($entity, $revision_id, $published);
}