From 73b750b27cfc6d838ee502427f6fa3e1757bd4b0 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 14 Apr 2017 07:56:04 +0100
Subject: [PATCH] Issue #2864060 by nlisgo, Lendude, alexpott:
 ModerationStateNodeTypeTest::testEnablingOnExistingContent assertion is
 misleading

---
 .../src/Tests/ModerationStateNodeTypeTest.php | 28 ++++++++++++++++---
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php
index 099b4dc61f9e..1911d9f2ba72 100644
--- a/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php
+++ b/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\content_moderation\Tests;
 
-
 /**
  * Tests moderation state node type integration.
  *
@@ -30,10 +29,25 @@ public function testNotModerated() {
    * Tests enabling moderation on an existing node-type, with content.
    */
   public function testEnablingOnExistingContent() {
+    $editor_permissions = [
+      'administer content moderation',
+      'access administration pages',
+      'administer content types',
+      'administer nodes',
+      'view latest version',
+      'view any unpublished content',
+      'access content overview',
+      'use editorial transition create_new_draft',
+    ];
+    $publish_permissions = array_merge($editor_permissions, ['use editorial transition publish']);
+    $editor = $this->drupalCreateUser($editor_permissions);
+    $editor_with_publish = $this->drupalCreateUser($publish_permissions);
+
     // Create a node type that is not moderated.
-    $this->drupalLogin($this->adminUser);
+    $this->drupalLogin($editor);
     $this->createContentTypeFromUi('Not moderated', 'not_moderated');
-    $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'not_moderated');
+    $this->grantUserPermissionToCreateContentOfType($editor, 'not_moderated');
+    $this->grantUserPermissionToCreateContentOfType($editor_with_publish, 'not_moderated');
 
     // Create content.
     $this->drupalGet('node/add/not_moderated');
@@ -68,7 +82,13 @@ public function testEnablingOnExistingContent() {
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->assertResponse(200);
     $this->assertRaw('Save and Create New Draft');
-    $this->assertNoRaw('Save and publish');
+    $this->assertNoRaw('Save and Publish');
+
+    $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');
   }
 
 }
-- 
GitLab