You are here

protected function WorkspacesContentModerationStateTest::createEntity in Drupal 9

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

Creates an entity.

The entity will have required fields populated and the corresponding bundle will be enabled for content moderation.

Parameters

string $entity_type_id: The entity type ID.

string $moderation_state: (optional) The initial moderation state of the newly created entity. Defaults to 'published'.

bool $create_workflow: (optional) Whether to create an editorial workflow and configure it for the given entity type. Defaults to TRUE.

Return value

\Drupal\Core\Entity\ContentEntityInterface The created entity.

Overrides ContentModerationStateTest::createEntity

File

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

Class

WorkspacesContentModerationStateTest
Tests that Workspaces and Content Moderation work together properly.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

protected function createEntity($entity_type_id, $moderation_state = 'published', $create_workflow = TRUE) {
  $entity = $this->workspaceManager
    ->executeOutsideWorkspace(function () use ($entity_type_id, $moderation_state, $create_workflow) {
    return parent::createEntity($entity_type_id, $moderation_state, $create_workflow);
  });
  return $entity;
}