diff --git a/tests/AsyncTestCase.php b/tests/AsyncTestCase.php index b459c42414b..d173857ff1e 100644 --- a/tests/AsyncTestCase.php +++ b/tests/AsyncTestCase.php @@ -12,6 +12,7 @@ use Psalm\Internal\RuntimeCaches; use Psalm\Internal\Type\TypeParser; use Psalm\Internal\Type\TypeTokenizer; +use Psalm\Internal\VersionUtils; use Psalm\IssueBuffer; use Psalm\Tests\Internal\Provider\FakeParserCacheProvider; use Psalm\Type\Union; @@ -40,11 +41,11 @@ public static function setUpBeforeClass(): void ini_set('memory_limit', '-1'); if (!defined('PSALM_VERSION')) { - define('PSALM_VERSION', '5.0.0'); + define('PSALM_VERSION', VersionUtils::getPsalmVersion()); } if (!defined('PHP_PARSER_VERSION')) { - define('PHP_PARSER_VERSION', '5.0.0'); + define('PHP_PARSER_VERSION', VersionUtils::getPhpParserVersion()); } parent::setUpBeforeClass(); diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index dd6a3fa6b80..c8e0f3a7c21 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -56,15 +56,9 @@ class ConfigTest extends TestCase public static function setUpBeforeClass(): void { - self::$config = new TestConfig(); - - if (!defined('PSALM_VERSION')) { - define('PSALM_VERSION', VersionUtils::getPsalmVersion()); - } + parent::setUpBeforeClass(); - if (!defined('PHP_PARSER_VERSION')) { - define('PHP_PARSER_VERSION', VersionUtils::getPhpParserVersion()); - } + self::$config = new TestConfig(); } public function setUp(): void @@ -1334,10 +1328,6 @@ function handleThrow(I $e) : void { public function testModularConfig(): void { - // hack to isolate Psalm from PHPUnit arguments - global $argv; - $argv = []; - $root = __DIR__ . '/../fixtures/ModularConfig'; $config = Config::loadFromXMLFile($root . '/psalm.xml', $root); $this->assertEquals( diff --git a/tests/Config/PluginTest.php b/tests/Config/PluginTest.php index 9c3297633f6..7aff0d97cef 100644 --- a/tests/Config/PluginTest.php +++ b/tests/Config/PluginTest.php @@ -44,19 +44,13 @@ class PluginTest extends TestCase public static function setUpBeforeClass(): void { + parent::setUpBeforeClass(); + // hack to isolate Psalm from PHPUnit cli arguments global $argv; $argv = []; self::$config = new TestConfig(); - - if (!defined('PSALM_VERSION')) { - define('PSALM_VERSION', VersionUtils::getPsalmVersion()); - } - - if (!defined('PHP_PARSER_VERSION')) { - define('PHP_PARSER_VERSION', VersionUtils::getPhpParserVersion()); - } } public function setUp(): void diff --git a/tests/ProjectCheckerTest.php b/tests/ProjectCheckerTest.php index da8f75fe0c2..d7667a8c98a 100644 --- a/tests/ProjectCheckerTest.php +++ b/tests/ProjectCheckerTest.php @@ -41,19 +41,13 @@ class ProjectCheckerTest extends TestCase public static function setUpBeforeClass(): void { + parent::setUpBeforeClass(); + // hack to stop Psalm seeing the phpunit arguments global $argv; $argv = []; self::$config = new TestConfig(); - - if (!defined('PSALM_VERSION')) { - define('PSALM_VERSION', VersionUtils::getPsalmVersion()); - } - - if (!defined('PHP_PARSER_VERSION')) { - define('PHP_PARSER_VERSION', VersionUtils::getPhpParserVersion()); - } } public function setUp(): void diff --git a/tests/StubTest.php b/tests/StubTest.php index 1e297daf976..013fdfbd9bc 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -35,15 +35,9 @@ class StubTest extends TestCase public static function setUpBeforeClass(): void { - self::$config = new TestConfig(); - - if (!defined('PSALM_VERSION')) { - define('PSALM_VERSION', VersionUtils::getPsalmVersion()); - } + parent::setUpBeforeClass(); - if (!defined('PHP_PARSER_VERSION')) { - define('PHP_PARSER_VERSION', VersionUtils::getPhpParserVersion()); - } + self::$config = new TestConfig(); } public function setUp(): void