diff --git a/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php b/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php index 58f637515de07f61a3afb7477e8cdd6a777f29ab..80cc70f575c388306f822d25f077cd08c67a3234 100644 --- a/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php +++ b/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php @@ -6,7 +6,9 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater; use Drupal\package_manager\Event\StageEvent; use Drupal\package_manager\Exception\StageException; use Drupal\package_manager\Exception\StageValidationException; +use Drupal\package_manager\Stage; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; +use Drupal\Tests\package_manager\Kernel\TestStage; use GuzzleHttp\Client; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; @@ -122,18 +124,14 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates */ class TestExtensionUpdater extends ExtensionUpdater { - /** - * The directory where staging areas will be created. - * - * @var string - */ - public static $stagingRoot; - /** * {@inheritdoc} */ - public function getStagingRoot(): string { - return static::$stagingRoot ?: parent::getStagingRoot(); + public function __construct(...$arguments) { + parent::__construct(...$arguments); + + $mirror = new \ReflectionClass(Stage::class); + $this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), TestStage::$stagingRoot); } /** diff --git a/package_manager/src/Stage.php b/package_manager/src/Stage.php index 6094a71552a5304d5d2812fba9804997513e0cfa..b2dcac50f79e9f10f3aba18e65d09b2a910a323e 100644 --- a/package_manager/src/Stage.php +++ b/package_manager/src/Stage.php @@ -73,7 +73,7 @@ class Stage { * * @see ::getStagingRoot() */ - protected const TEMPSTORE_STAGING_ROOT_KEY = 'staging_root'; + private const TEMPSTORE_STAGING_ROOT_KEY = 'staging_root'; /** * The tempstore key under which to store the time that ::apply() was called. @@ -408,7 +408,7 @@ class Stage { protected function markAsAvailable(): void { $this->tempStore->delete(static::TEMPSTORE_METADATA_KEY); $this->tempStore->delete(static::TEMPSTORE_LOCK_KEY); - $this->tempStore->delete(static::TEMPSTORE_STAGING_ROOT_KEY); + $this->tempStore->delete(self::TEMPSTORE_STAGING_ROOT_KEY); $this->lock = NULL; } @@ -560,15 +560,15 @@ class Stage { * The absolute path of the directory containing the staging areas managed * by this class. */ - protected function getStagingRoot(): string { + private function getStagingRoot(): string { // Since the staging root can depend on site settings, store it so that // things won't break if the settings change during this stage's life // cycle. - $dir = $this->tempStore->get(static::TEMPSTORE_STAGING_ROOT_KEY); + $dir = $this->tempStore->get(self::TEMPSTORE_STAGING_ROOT_KEY); if (empty($dir)) { $site_id = $this->configFactory->get('system.site')->get('uuid'); $dir = $this->fileSystem->getTempDirectory() . DIRECTORY_SEPARATOR . '.package_manager' . $site_id; - $this->tempStore->set(static::TEMPSTORE_STAGING_ROOT_KEY, $dir); + $this->tempStore->set(self::TEMPSTORE_STAGING_ROOT_KEY, $dir); } return $dir; } diff --git a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php index 6a929245f0c84abd25e29746e7920746b2e56969..793253504af5a7d24ad090397b5760bf5b6a4459 100644 --- a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php +++ b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php @@ -244,8 +244,11 @@ class TestStage extends Stage { /** * {@inheritdoc} */ - public function getStagingRoot(): string { - return static::$stagingRoot ?: parent::getStagingRoot(); + public function __construct(...$arguments) { + parent::__construct(...$arguments); + + $mirror = new \ReflectionClass(parent::class); + $this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), static::$stagingRoot); } /** diff --git a/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php b/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php index a3c260ac61ca317e3e9d356a10a00d95d582139e..1679f69b628a82d806f2072e653b3b5d115333dc 100644 --- a/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php +++ b/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\automatic_updates\Kernel; use Drupal\automatic_updates\CronUpdater; use Drupal\automatic_updates\Updater; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\package_manager\Stage; use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait; use Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase; use Drupal\Tests\package_manager\Kernel\TestStage; @@ -153,8 +154,11 @@ class TestUpdater extends Updater { /** * {@inheritdoc} */ - public function getStagingRoot(): string { - return TestStage::$stagingRoot ?: parent::getStagingRoot(); + public function __construct(...$arguments) { + parent::__construct(...$arguments); + + $mirror = new \ReflectionClass(Stage::class); + $this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), TestStage::$stagingRoot); } } @@ -167,8 +171,11 @@ class TestCronUpdater extends CronUpdater { /** * {@inheritdoc} */ - public function getStagingRoot(): string { - return TestStage::$stagingRoot ?: parent::getStagingRoot(); + public function __construct(...$arguments) { + parent::__construct(...$arguments); + + $mirror = new \ReflectionClass(Stage::class); + $this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), TestStage::$stagingRoot); } }