From 42a48a2e2b8e758aa1225dda60c26fc6318e1416 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 13 Dec 2021 13:04:50 +0000
Subject: [PATCH] Issue #3253639 by tedbow, longwave:
 \Drupal\Tests\update\Functional\UpdateTestBase::setUp is not needed for most
 child classes and makes the test harder to understand

---
 .../FileTransferAuthorizeFormTest.php         |  2 +-
 .../tests/src/Functional/UpdateTestBase.php   | 23 ------------
 .../tests/src/Functional/UpdateUploadTest.php |  2 +-
 .../src/Functional/UpdateUploaderTestBase.php | 37 +++++++++++++++++++
 4 files changed, 39 insertions(+), 25 deletions(-)
 create mode 100644 core/modules/update/tests/src/Functional/UpdateUploaderTestBase.php

diff --git a/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php b/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php
index 58fda4cf9e8e..833b0d3b1ae5 100644
--- a/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php
+++ b/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php
@@ -7,7 +7,7 @@
  *
  * @group update
  */
-class FileTransferAuthorizeFormTest extends UpdateTestBase {
+class FileTransferAuthorizeFormTest extends UpdateUploaderTestBase {
 
   /**
    * Modules to enable.
diff --git a/core/modules/update/tests/src/Functional/UpdateTestBase.php b/core/modules/update/tests/src/Functional/UpdateTestBase.php
index 3ce554831731..8ab357424c65 100644
--- a/core/modules/update/tests/src/Functional/UpdateTestBase.php
+++ b/core/modules/update/tests/src/Functional/UpdateTestBase.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\update\Functional;
 
-use Drupal\Core\DrupalKernel;
 use Drupal\Core\Url;
 use Drupal\Tests\BrowserTestBase;
 
@@ -54,28 +53,6 @@ abstract class UpdateTestBase extends BrowserTestBase {
    */
   protected $updateProject;
 
-  protected function setUp() {
-    parent::setUp();
-
-    // Change the root path which Update Manager uses to install and update
-    // projects to be inside the testing site directory. See
-    // \Drupal\update\UpdateRootFactory::get() for equivalent changes to the
-    // test child site.
-    $request = \Drupal::request();
-    $update_root = $this->container->get('update.root') . '/' . DrupalKernel::findSitePath($request);
-    $this->container->get('update.root')->set($update_root);
-
-    // Create the directories within the root path within which the Update
-    // Manager will install projects.
-    foreach (drupal_get_updaters() as $updater_info) {
-      $updater = $updater_info['class'];
-      $install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath();
-      if (!is_dir($install_directory)) {
-        mkdir($install_directory);
-      }
-    }
-  }
-
   /**
    * Refreshes the update status based on the desired available update scenario.
    *
diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php
index 4d447c17ead9..c3212f5f5639 100644
--- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php
+++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php
@@ -12,7 +12,7 @@
  *
  * @group update
  */
-class UpdateUploadTest extends UpdateTestBase {
+class UpdateUploadTest extends UpdateUploaderTestBase {
 
   use TestFileCreationTrait {
     getTestFiles as drupalGetTestFiles;
diff --git a/core/modules/update/tests/src/Functional/UpdateUploaderTestBase.php b/core/modules/update/tests/src/Functional/UpdateUploaderTestBase.php
new file mode 100644
index 000000000000..972495444d93
--- /dev/null
+++ b/core/modules/update/tests/src/Functional/UpdateUploaderTestBase.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Drupal\Tests\update\Functional;
+
+use Drupal\Core\DrupalKernel;
+
+/**
+ * Base test class for tests that test project upload functionality.
+ */
+class UpdateUploaderTestBase extends UpdateTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Change the root path which Update Manager uses to install and update
+    // projects to be inside the testing site directory. See
+    // \Drupal\update\UpdateRootFactory::get() for equivalent changes to the
+    // test child site.
+    $request = \Drupal::request();
+    $update_root = $this->container->get('update.root') . '/' . DrupalKernel::findSitePath($request);
+    $this->container->get('update.root')->set($update_root);
+
+    // Create the directories within the root path within which the Update
+    // Manager will install projects.
+    foreach (drupal_get_updaters() as $updater_info) {
+      $updater = $updater_info['class'];
+      $install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath();
+      if (!is_dir($install_directory)) {
+        mkdir($install_directory);
+      }
+    }
+  }
+
+}
-- 
GitLab