From a02a2715afeaac313643791d4c03545d87fa38d3 Mon Sep 17 00:00:00 2001
From: Ted Bowman <ted@tedbow.com>
Date: Thu, 5 May 2022 12:20:18 -0400
Subject: [PATCH] use test class var instead of TestStage

---
 .../src/Kernel/PackageManagerKernelTestBase.php   | 15 +++++++++++++--
 .../StagedDatabaseUpdateValidatorTest.php         |  2 +-
 .../StagedProjectsValidatorTest.php               |  4 ++--
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
index be46b3414d..5171075abe 100644
--- a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
+++ b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
@@ -31,6 +31,17 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
     'package_manager_bypass',
   ];
 
+  /**
+   * The test staging root.
+   *
+   * This value must be set before create an test stage instance.
+   *
+   * @var string
+   *
+   * @see \Drupal\Tests\package_manager\Kernel\TestStageTrait::setStagingRoot()
+   */
+  public static $testStagingRoot;
+
   /**
    * The service IDs of any validators to disable.
    *
@@ -175,7 +186,7 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
     // Create a staging root directory alongside the active directory.
     $stage_dir = vfsStream::newDirectory('stage');
     $this->vfsRoot->addChild($stage_dir);
-    TestStage::$stagingRoot = $stage_dir->url();
+    static::$testStagingRoot = $stage_dir->url();
 
     $path_locator = $this->mockPathLocator($active_dir->url());
 
@@ -254,7 +265,7 @@ trait TestStageTrait {
    */
   protected function setStagingRoot(): void {
     $mirror = new \ReflectionClass(Stage::class);
-    $this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), TestStage::$stagingRoot);
+    $this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), PackageManagerKernelTestBase::$testStagingRoot);
   }
 
   /**
diff --git a/tests/src/Kernel/ReadinessValidation/StagedDatabaseUpdateValidatorTest.php b/tests/src/Kernel/ReadinessValidation/StagedDatabaseUpdateValidatorTest.php
index 142d7d9e21..0a2d913ec8 100644
--- a/tests/src/Kernel/ReadinessValidation/StagedDatabaseUpdateValidatorTest.php
+++ b/tests/src/Kernel/ReadinessValidation/StagedDatabaseUpdateValidatorTest.php
@@ -36,7 +36,7 @@ class StagedDatabaseUpdateValidatorTest extends AutomaticUpdatesKernelTestBase {
     $this->disableValidators[] = 'package_manager.validator.lock_file';
     parent::setUp();
 
-    TestStage::$stagingRoot = $this->vfsRoot->url();
+    static::$testStagingRoot = $this->vfsRoot->url();
 
     /** @var \Drupal\Tests\automatic_updates\Kernel\TestCronUpdater $updater */
     $updater = $this->container->get('automatic_updates.cron_updater');
diff --git a/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php b/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php
index 1bddb5dcd0..c3a6688a0e 100644
--- a/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php
+++ b/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php
@@ -52,12 +52,12 @@ class StagedProjectsValidatorTest extends AutomaticUpdatesKernelTestBase {
       // subdirectory using the stage ID after it is created below.
       $stage_vfs_dir = vfsStream::newDirectory('au_stage');
       $this->vfsRoot->addChild($stage_vfs_dir);
-      TestStage::$stagingRoot = $stage_vfs_dir->url();
+      static::$testStagingRoot = $stage_vfs_dir->url();
     }
     else {
       // If we are testing non-existent staging directory we can use the path
       // directly.
-      TestStage::$stagingRoot = $stage_dir;
+      static::$testStagingRoot = $stage_dir;
     }
 
     $updater = $this->container->get('automatic_updates.updater');
-- 
GitLab