function ContentModerationTestTrait::createEditorialWorkflow

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Traits/ContentModerationTestTrait.php \Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait::createEditorialWorkflow()
  2. 8.9.x core/modules/content_moderation/tests/src/Traits/ContentModerationTestTrait.php \Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait::createEditorialWorkflow()
  3. 10 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.

56 calls to ContentModerationTestTrait::createEditorialWorkflow()
BookContentModerationTest::setUp in core/modules/book/tests/src/Functional/BookContentModerationTest.php
ContentModerationAccessTest::setUp in core/modules/content_moderation/tests/src/Kernel/ContentModerationAccessTest.php
ContentModerationResaveTest::setUp in core/modules/content_moderation/tests/src/Kernel/ContentModerationResaveTest.php
ContentModerationStateStorageSchemaTest::setUp in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php
ContentModerationStateTest::createEntity in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
Creates an entity.

... See full list

1 method overrides ContentModerationTestTrait::createEditorialWorkflow()
WorkspacesContentModerationStateTest::createEditorialWorkflow in core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php
Creates the editorial workflow.

File

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

Class

ContentModerationTestTrait
Provides functionality for testing content moderation.

Namespace

Drupal\Tests\content_moderation\Traits

Code

protected function createEditorialWorkflow() {
    // Allow this method to be called twice from the same test method.
    if ($workflow = Workflow::load('editorial')) {
        return $workflow;
    }
    $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.