X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_moderation%2Ftests%2Fsrc%2FFunctional%2FModerationStateBlockTest.php;h=8b02848a30c2bbf568e94ba0019f56ead5a091d5;hp=d45fb7b33737eed9db896c4e390da24bb41f3807;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php b/web/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php index d45fb7b33..8b02848a3 100644 --- a/web/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php +++ b/web/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php @@ -51,25 +51,18 @@ class ModerationStateBlockTest extends ModerationStateTestBase { public function testCustomBlockModeration() { $this->drupalLogin($this->rootUser); - $this->drupalGet('admin/structure/block/block-content/types'); - $this->assertLinkByHref('admin/structure/block/block-content/manage/basic/moderation'); - $this->drupalGet('admin/structure/block/block-content/manage/basic'); - $this->assertLinkByHref('admin/structure/block/block-content/manage/basic/moderation'); - $this->drupalGet('admin/structure/block/block-content/manage/basic/moderation'); - - // Enable moderation for custom blocks at - // admin/structure/block/block-content/manage/basic/moderation. - $edit = ['workflow' => 'editorial']; - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('Your settings have been saved.')); + // Enable moderation for custom blocks. + $edit['bundles[basic]'] = TRUE; + $this->drupalPostForm('admin/config/workflow/workflows/manage/editorial/type/block_content', $edit, t('Save')); // Create a custom block at block/add and save it as draft. $body = 'Body of moderated block'; $edit = [ 'info[0][value]' => 'Moderated block', + 'moderation_state[0][state]' => 'draft', 'body[0][value]' => $body, ]; - $this->drupalPostForm('block/add', $edit, t('Save and Create New Draft')); + $this->drupalPostForm('block/add', $edit, t('Save')); $this->assertText(t('basic Moderated block has been created.')); // Place the block in the Sidebar First region. @@ -91,8 +84,9 @@ class ModerationStateBlockTest extends ModerationStateTestBase { $updated_body = 'This is the new body value'; $edit = [ 'body[0][value]' => $updated_body, + 'moderation_state[0][state]' => 'draft', ]; - $this->drupalPostForm('block/' . $block->id(), $edit, t('Save and Create New Draft')); + $this->drupalPostForm('block/' . $block->id(), $edit, t('Save')); $this->assertText(t('basic Moderated block has been updated.')); // Navigate to the home page and check that the block shows the updated @@ -101,18 +95,21 @@ class ModerationStateBlockTest extends ModerationStateTestBase { $this->drupalGet(''); $this->assertText($updated_body); - // Publish the block so we can create a forward revision. - $this->drupalPostForm('block/' . $block->id(), [], t('Save and Publish')); + // Publish the block so we can create a pending revision. + $this->drupalPostForm('block/' . $block->id(), [ + 'moderation_state[0][state]' => 'published', + ], t('Save')); - // Create a forward revision. - $forward_revision_body = 'This is the forward revision body value'; + // Create a pending revision. + $pending_revision_body = 'This is the pending revision body value'; $edit = [ - 'body[0][value]' => $forward_revision_body, + 'body[0][value]' => $pending_revision_body, + 'moderation_state[0][state]' => 'draft', ]; - $this->drupalPostForm('block/' . $block->id(), $edit, t('Save and Create New Draft')); + $this->drupalPostForm('block/' . $block->id(), $edit, t('Save')); $this->assertText(t('basic Moderated block has been updated.')); - // Navigate to home page and check that the forward revision doesn't show, + // Navigate to home page and check that the pending revision doesn't show, // since it should not be set as the default revision. $this->drupalGet(''); $this->assertText($updated_body); @@ -124,10 +121,17 @@ class ModerationStateBlockTest extends ModerationStateTestBase { $this->drupalPostForm('block/' . $block->id() . '/latest', $edit, t('Apply')); $this->assertText(t('The moderation state has been updated.')); - // Navigate to home page and check that the forward revision is now the + // Navigate to home page and check that the pending revision is now the // default revision and therefore visible. $this->drupalGet(''); - $this->assertText($forward_revision_body); + $this->assertText($pending_revision_body); + + // Check that revision is checked by default when content moderation is + // enabled. + $this->drupalGet('/block/' . $block->id()); + $this->assertSession()->checkboxChecked('revision'); + $this->assertText('Revisions must be required when moderation is enabled.'); + $this->assertSession()->fieldDisabled('revision'); } }