Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / content_moderation / tests / src / Functional / ModerationStateNodeTypeTest.php
index 8391dd0aaea1a2d47113b40a9954194ced088acf..e8d8ccd8df0606eba698e3a3ad1742b3d47424e3 100644 (file)
@@ -11,6 +11,9 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase {
 
   /**
    * A node type without moderation state disabled.
+   *
+   * @covers \Drupal\content_moderation\EntityTypeInfo::formAlter
+   * @covers \Drupal\content_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsBundleFormAlter
    */
   public function testNotModerated() {
     $this->drupalLogin($this->adminUser);
@@ -18,19 +21,22 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase {
     $this->assertText('The content type Not moderated has been added.');
     $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'not_moderated');
     $this->drupalGet('node/add/not_moderated');
-    $this->assertRaw('Save as unpublished');
+    $this->assertRaw('Save');
     $this->drupalPostForm(NULL, [
       'title[0][value]' => 'Test',
-    ], t('Save and publish'));
+    ], t('Save'));
     $this->assertText('Not moderated Test has been created.');
   }
 
   /**
    * Tests enabling moderation on an existing node-type, with content.
+   *
+   * @covers \Drupal\content_moderation\EntityTypeInfo::formAlter
+   * @covers \Drupal\content_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsBundleFormAlter
    */
   public function testEnablingOnExistingContent() {
     $editor_permissions = [
-      'administer content moderation',
+      'administer workflows',
       'access administration pages',
       'administer content types',
       'administer nodes',
@@ -53,20 +59,11 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase {
     $this->drupalGet('node/add/not_moderated');
     $this->drupalPostForm(NULL, [
       'title[0][value]' => 'Test',
-    ], t('Save and publish'));
+    ], t('Save'));
     $this->assertText('Not moderated Test has been created.');
 
-    // Now enable moderation state, ensuring all the expected links and tabs are
-    // present.
-    $this->drupalGet('admin/structure/types');
-    $this->assertLinkByHref('admin/structure/types/manage/not_moderated/moderation');
-    $this->drupalGet('admin/structure/types/manage/not_moderated');
-    $this->assertLinkByHref('admin/structure/types/manage/not_moderated/moderation');
-    $this->drupalGet('admin/structure/types/manage/not_moderated/moderation');
-    $this->assertOptionSelected('edit-workflow', '');
-    $this->assertNoLink('Delete');
-    $edit['workflow'] = 'editorial';
-    $this->drupalPostForm(NULL, $edit, t('Save'));
+    // Now enable moderation state.
+    $this->enableModerationThroughUi('not_moderated');
 
     // And make sure it works.
     $nodes = \Drupal::entityTypeManager()->getStorage('node')
@@ -81,14 +78,14 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase {
     $this->assertLinkByHref('node/' . $node->id() . '/edit');
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->assertResponse(200);
-    $this->assertRaw('Save and Create New Draft');
-    $this->assertNoRaw('Save and Publish');
+    $this->assertSession()->optionExists('moderation_state[0][state]', 'draft');
+    $this->assertSession()->optionNotExists('moderation_state[0][state]', 'published');
 
     $this->drupalLogin($editor_with_publish);
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->assertResponse(200);
-    $this->assertRaw('Save and Create New Draft');
-    $this->assertRaw('Save and Publish');
+    $this->assertSession()->optionExists('moderation_state[0][state]', 'draft');
+    $this->assertSession()->optionExists('moderation_state[0][state]', 'published');
   }
 
 }