Skip to content

Commit 3e92a56

Browse files
committed
test: reset PHP versions after each test class
Required, as test success is currently order-dependent and may prevent running specific subgroups of tests. The reason being that the PHP version is set via simple parameters, which are global and previously unable to be unset. Some tests required setting the specific version of PHP, which would end up pinning that version until the next test that required a specific version. If the prior version was too low, it could cause later tests not to execute at all, breaking things. You could not set the version parameter to `null` because it's always accessed via `provideIntParameter(...)`, which does type-checking.
1 parent 6a31016 commit 3e92a56

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/Configuration/Parameter/SimpleParameterProvider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public static function setParameter(string $name, mixed $value): void
3939
self::$parameters[$name] = $value;
4040
}
4141

42+
/**
43+
* @param Option::* $name
44+
*/
45+
public static function unsetParameter(string $name): void
46+
{
47+
unset(self::$parameters[$name]);
48+
}
49+
4250
/**
4351
* @param Option::* $name
4452
* @return mixed[]

src/Testing/PHPUnit/AbstractRectorTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ abstract class AbstractRectorTestCase extends AbstractLazyTestCase implements Re
5050
*/
5151
public static function tearDownAfterClass(): void
5252
{
53+
SimpleParameterProvider::unsetParameter(Option::PHP_VERSION_FEATURES);
54+
5355
SimpleParameterProvider::setParameter(Option::AUTO_IMPORT_NAMES, false);
5456
SimpleParameterProvider::setParameter(Option::AUTO_IMPORT_DOC_BLOCK_NAMES, false);
5557
SimpleParameterProvider::setParameter(Option::REMOVE_UNUSED_IMPORTS, false);

0 commit comments

Comments
 (0)