From 8bb1852395c93d18e1d385a9771392dcac817823 Mon Sep 17 00:00:00 2001
From: tedbow <tedbow@240860.no-reply.drupal.org>
Date: Tue, 7 Jun 2022 18:42:15 +0000
Subject: [PATCH] Issue #3284495 by tedbow: Tests failing on 9.3.x

---
 .../UpdaterFormNoRecommendedReleaseMessageTest.php   |  9 +++++++--
 tests/src/Functional/UpdaterFormTest.php             | 12 ++++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php b/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php
index d8cef338eb..2c604a7058 100644
--- a/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php
+++ b/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php
@@ -85,12 +85,17 @@ class UpdaterFormNoRecommendedReleaseMessageTest extends AutomaticUpdatesFunctio
     $this->drupalGet('/admin/reports/updates/automatic-update');
 
     $assert_session = $this->assertSession();
+    // BEGIN: DELETE FROM CORE MERGE REQUEST
+    // @todo Use \Drupal\Tests\WebAssert::statusMessageContains() when module
+    //   drops support for Drupal core 9.3.x.
+    // END: DELETE FROM CORE MERGE REQUEST
+    $message_selector = $expected_message_type === 'status' ? "//div[@role='contentinfo' and h2[text()='Status message']]" : "//div[@role='alert' and h2[text()='Error message']]";
     if ($updates_available) {
-      $assert_session->statusMessageContains('Updates were found, but they must be performed manually.', $expected_message_type);
+      $assert_session->elementTextContains('xpath', $message_selector, 'Updates were found, but they must be performed manually.');
       $assert_session->linkExists('the list of available updates');
     }
     else {
-      $assert_session->statusMessageContains('No update available', $expected_message_type);
+      $assert_session->elementTextContains('xpath', $message_selector, 'No update available');
     }
     $assert_session->buttonNotExists('Update');
   }
diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php
index fd4a157606..f73f37443f 100644
--- a/tests/src/Functional/UpdaterFormTest.php
+++ b/tests/src/Functional/UpdaterFormTest.php
@@ -50,7 +50,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
     parent::setUp();
 
     $this->setReleaseMetadata(__DIR__ . '/../../fixtures/release-history/drupal.9.8.1-security.xml');
-    $user = $this->createUser([
+    $permissions = [
       'administer site configuration',
       'administer software updates',
       'access administration pages',
@@ -58,7 +58,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
       'administer modules',
       'access site reports',
       'view update notifications',
-    ]);
+    ];
+    // BEGIN: DELETE FROM CORE MERGE REQUEST
+    // Check for permission that was added in Drupal core 9.4.x.
+    $available_permissions = array_keys($this->container->get('user.permissions')->getPermissions());
+    if (!in_array('view update notifications', $available_permissions)) {
+      array_pop($permissions);
+    }
+    // END: DELETE FROM CORE MERGE REQUEST
+    $user = $this->createUser($permissions);
     $this->drupalLogin($user);
     $this->checkForUpdates();
   }
-- 
GitLab