From 7591ef0084b5e1349824ceb9f2fd3955fee8155d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 2 Feb 2022 16:08:36 +0100 Subject: [PATCH] Attempt fixing usage of InstalledVersions in tests --- tests/Composer/Test/InstalledVersionsTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/Composer/Test/InstalledVersionsTest.php b/tests/Composer/Test/InstalledVersionsTest.php index d66005b54..4c27b2e0f 100644 --- a/tests/Composer/Test/InstalledVersionsTest.php +++ b/tests/Composer/Test/InstalledVersionsTest.php @@ -17,6 +17,8 @@ use Composer\Semver\VersionParser; class InstalledVersionsTest extends TestCase { + private static $previousRegisteredLoaders; + /** * @var string */ @@ -28,12 +30,16 @@ class InstalledVersionsTest extends TestCase // class loaders are registered $prop = new \ReflectionProperty('Composer\Autoload\ClassLoader', 'registeredLoaders'); $prop->setAccessible(true); + self::$previousRegisteredLoaders = $prop->getValue(); $prop->setValue(array()); } public static function tearDownAfterClass() { - self::setUpBeforeClass(); + $prop = new \ReflectionProperty('Composer\Autoload\ClassLoader', 'registeredLoaders'); + $prop->setAccessible(true); + $prop->setValue(self::$previousRegisteredLoaders); + InstalledVersions::reload(null); // @phpstan-ignore-line } public function setUp()