3 namespace Drupal\Tests\content_moderation\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Test the workflow type plugin in the content_moderation module.
10 * @group content_moderation
12 class ContentModerationWorkflowTypeTest extends BrowserTestBase {
19 public static $modules = [
27 protected function setUp() {
29 $admin = $this->drupalCreateUser([
30 'administer workflows',
32 $this->drupalLogin($admin);
36 * Test creating a new workflow using the content moderation plugin.
38 public function testNewWorkflow() {
39 $entity_bundle_info = \Drupal::service('entity_type.bundle.info');
41 $this->drupalPostForm('admin/config/workflow/workflows/add', [
42 'label' => 'Test Workflow',
43 'id' => 'test_workflow',
44 'workflow_type' => 'content_moderation',
47 // Make sure the test workflow includes the default states and transitions.
48 $this->assertSession()->pageTextContains('Draft');
49 $this->assertSession()->pageTextContains('Published');
50 $this->assertSession()->pageTextContains('Create New Draft');
51 $this->assertSession()->pageTextContains('Publish');
53 // Ensure after a workflow is created, the bundle information can be
55 $entity_bundle_info->clearCachedBundles();
56 $this->assertNotEmpty($entity_bundle_info->getAllBundleInfo());
58 $this->clickLink('Add a new state');
60 'label' => 'Test State',
62 'type_settings[content_moderation][published]' => TRUE,
63 'type_settings[content_moderation][default_revision]' => FALSE,
65 $this->assertSession()->pageTextContains('Created Test State state.');
67 // Ensure that the published settings cannot be changed.
68 $this->drupalGet('admin/config/workflow/workflows/manage/test_workflow/state/published');
69 $this->assertSession()->fieldDisabled('type_settings[content_moderation][published]');
70 $this->assertSession()->fieldDisabled('type_settings[content_moderation][default_revision]');
72 // Ensure that the draft settings cannot be changed.
73 $this->drupalGet('admin/config/workflow/workflows/manage/test_workflow/state/draft');
74 $this->assertSession()->fieldDisabled('type_settings[content_moderation][published]');
75 $this->assertSession()->fieldDisabled('type_settings[content_moderation][default_revision]');