X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fcontent_moderation%2Ftests%2Fsrc%2FFunctional%2FContentModerationWorkflowTypeTest.php;fp=web%2Fcore%2Fmodules%2Fcontent_moderation%2Ftests%2Fsrc%2FFunctional%2FContentModerationWorkflowTypeTest.php;h=ff37bd11a99d69be6d35b54ba49feaefcc915b14;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/content_moderation/tests/src/Functional/ContentModerationWorkflowTypeTest.php b/web/core/modules/content_moderation/tests/src/Functional/ContentModerationWorkflowTypeTest.php new file mode 100644 index 000000000..ff37bd11a --- /dev/null +++ b/web/core/modules/content_moderation/tests/src/Functional/ContentModerationWorkflowTypeTest.php @@ -0,0 +1,78 @@ +drupalCreateUser([ + 'administer workflows', + ]); + $this->drupalLogin($admin); + } + + /** + * Test creating a new workflow using the content moderation plugin. + */ + public function testNewWorkflow() { + $entity_bundle_info = \Drupal::service('entity_type.bundle.info'); + + $this->drupalPostForm('admin/config/workflow/workflows/add', [ + 'label' => 'Test Workflow', + 'id' => 'test_workflow', + 'workflow_type' => 'content_moderation', + ], 'Save'); + + // Make sure the test workflow includes the default states and transitions. + $this->assertSession()->pageTextContains('Draft'); + $this->assertSession()->pageTextContains('Published'); + $this->assertSession()->pageTextContains('Create New Draft'); + $this->assertSession()->pageTextContains('Publish'); + + // Ensure after a workflow is created, the bundle information can be + // refreshed. + $entity_bundle_info->clearCachedBundles(); + $this->assertNotEmpty($entity_bundle_info->getAllBundleInfo()); + + $this->clickLink('Add a new state'); + $this->submitForm([ + 'label' => 'Test State', + 'id' => 'test_state', + 'type_settings[content_moderation][published]' => TRUE, + 'type_settings[content_moderation][default_revision]' => FALSE, + ], 'Save'); + $this->assertSession()->pageTextContains('Created Test State state.'); + + // Ensure that the published settings cannot be changed. + $this->drupalGet('admin/config/workflow/workflows/manage/test_workflow/state/published'); + $this->assertSession()->fieldDisabled('type_settings[content_moderation][published]'); + $this->assertSession()->fieldDisabled('type_settings[content_moderation][default_revision]'); + + // Ensure that the draft settings cannot be changed. + $this->drupalGet('admin/config/workflow/workflows/manage/test_workflow/state/draft'); + $this->assertSession()->fieldDisabled('type_settings[content_moderation][published]'); + $this->assertSession()->fieldDisabled('type_settings[content_moderation][default_revision]'); + } + +}