Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / menu_ui / src / Tests / MenuNodeTest.php
index 3f1bba06ee86d081c006ff75c8675530a95f305a..99900955fb0f79bb96a6aae5a0d6eaab123bb67e 100644 (file)
@@ -134,8 +134,7 @@ class MenuNodeTest extends WebTestBase {
     $this->drupalGet('test-page');
     $this->assertNoLink($node_title);
 
-    // Use not only the save button, but also the two special buttons:
-    // 'Save and publish' as well as 'Save and keep published'.
+    // Make sure the menu links only appear when the node is published.
     // These buttons just appear for 'administer nodes' users.
     $admin_user = $this->drupalCreateUser([
       'access administration pages',
@@ -146,21 +145,20 @@ class MenuNodeTest extends WebTestBase {
       'edit any page content',
     ]);
     $this->drupalLogin($admin_user);
-    foreach (['Save and unpublish' => FALSE, 'Save and keep unpublished' => FALSE, 'Save and publish' => TRUE, 'Save and keep published' => TRUE] as $submit => $visible) {
-      $edit = [
-        'menu[enabled]' => 1,
-        'menu[title]' => $node_title,
-      ];
-      $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, $submit);
-      // Assert that the link exists.
-      $this->drupalGet('test-page');
-      if ($visible) {
-        $this->assertLink($node_title, 0, 'Found a menu link after submitted with ' . $submit);
-      }
-      else {
-        $this->assertNoLink($node_title, 'Found no menu link after submitted with ' . $submit);
-      }
-    }
+    // Assert that the link does not exist if unpublished.
+    $edit = [
+      'menu[enabled]' => 1,
+      'menu[title]' => $node_title,
+      'status[value]' => FALSE,
+    ];
+    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save');
+    $this->drupalGet('test-page');
+    $this->assertNoLink($node_title, 'Found no menu link with the node unpublished');
+    // Assert that the link exists if published.
+    $edit['status[value]'] = TRUE;
+    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save');
+    $this->drupalGet('test-page');
+    $this->assertLink($node_title, 0, 'Found a menu link with the node published');
 
     // Log back in as normal user.
     $this->drupalLogin($this->editor);