You are here

protected function ContentModerationTestTrait::createEditorialWorkflow in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Traits/ContentModerationTestTrait.php \Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait::createEditorialWorkflow()
  2. 9 core/modules/content_moderation/tests/src/Traits/ContentModerationTestTrait.php \Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait::createEditorialWorkflow()

Creates the editorial workflow.

Return value

\Drupal\workflows\Entity\Workflow The editorial workflow entity.

3 calls to ContentModerationTestTrait::createEditorialWorkflow()
MigrateDrupal6AuditIdsTest::setUp in core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php
MigrateDrupal7AuditIdsTest::setUp in core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php
ModeratedNodeResourceTestBase::createEntity in core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php
Creates the entity to be tested.

File

core/modules/content_moderation/tests/src/Traits/ContentModerationTestTrait.php, line 19

Class

ContentModerationTestTrait
Provides functionality for testing content moderation.

Namespace

Drupal\Tests\content_moderation\Traits

Code

protected function createEditorialWorkflow() {
  $workflow = Workflow::create([
    'type' => 'content_moderation',
    'id' => 'editorial',
    'label' => 'Editorial',
    'type_settings' => [
      'states' => [
        'archived' => [
          'label' => 'Archived',
          'weight' => 5,
          'published' => FALSE,
          'default_revision' => TRUE,
        ],
        'draft' => [
          'label' => 'Draft',
          'published' => FALSE,
          'default_revision' => FALSE,
          'weight' => -5,
        ],
        'published' => [
          'label' => 'Published',
          'published' => TRUE,
          'default_revision' => TRUE,
          'weight' => 0,
        ],
      ],
      'transitions' => [
        'archive' => [
          'label' => 'Archive',
          'from' => [
            'published',
          ],
          'to' => 'archived',
          'weight' => 2,
        ],
        'archived_draft' => [
          'label' => 'Restore to Draft',
          'from' => [
            'archived',
          ],
          'to' => 'draft',
          'weight' => 3,
        ],
        'archived_published' => [
          'label' => 'Restore',
          'from' => [
            'archived',
          ],
          'to' => 'published',
          'weight' => 4,
        ],
        'create_new_draft' => [
          'label' => 'Create New Draft',
          'to' => 'draft',
          'weight' => 0,
          'from' => [
            'draft',
            'published',
          ],
        ],
        'publish' => [
          'label' => 'Publish',
          'to' => 'published',
          'weight' => 1,
          'from' => [
            'draft',
            'published',
          ],
        ],
      ],
    ],
  ]);
  $workflow
    ->save();
  return $workflow;
}