Tests: Improve PHPUnit version retrieval.

Always test for newer class names first and fall back to the older.

This improves compatibility when running PHPUnit via a phar while there is also a Composer-installed version of PHPUnit on the system.

Props jrf.
See #52625.

git-svn-id: https://develop.svn.wordpress.org/trunk@50982 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-05-24 21:03:15 +00:00
parent c3ef52ded7
commit 479ea22b8e

View File

@ -7,10 +7,10 @@ require_once __DIR__ . '/class-basic-object.php';
* @return double The version number.
*/
function tests_get_phpunit_version() {
if ( class_exists( 'PHPUnit_Runner_Version' ) ) {
$version = PHPUnit_Runner_Version::id();
} elseif ( class_exists( 'PHPUnit\Runner\Version' ) ) {
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
$version = PHPUnit\Runner\Version::id();
} elseif ( class_exists( 'PHPUnit_Runner_Version' ) ) {
$version = PHPUnit_Runner_Version::id();
} else {
$version = 0;
}