From 67f31935d0be7ef27dc420851da5867583a2e5fd Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 6 Jul 2021 11:33:27 +0000 Subject: [PATCH] Tests: Move loading compatibility layers for PHPUnit 6+ and 7.5+ closer together. Follow-up to [40536], [44701], [50986]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51333 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/bootstrap.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index f059590ac1..ce50a89534 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -3,13 +3,6 @@ * Installs WordPress for running the tests and loads WordPress and the test libraries */ -/** - * Compatibility with PHPUnit 6+ - */ -if ( class_exists( 'PHPUnit\Runner\Version' ) ) { - require_once __DIR__ . '/phpunit6/compat.php'; -} - if ( defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) { $config_file_path = WP_TESTS_CONFIG_FILE_PATH; } else { @@ -193,6 +186,12 @@ require_once ABSPATH . '/wp-settings.php'; // Delete any default posts & related data. _delete_all_posts(); +// Load class aliases for compatibility with PHPUnit 6+. +if ( version_compare( tests_get_phpunit_version(), '6.0', '>=' ) ) { + require __DIR__ . '/phpunit6/compat.php'; +} + +// Load separate WP_UnitTestCase classes for PHPUnit 7.5+ and older versions. if ( version_compare( tests_get_phpunit_version(), '7.5', '>=' ) ) { require __DIR__ . '/phpunit7/testcase.php'; } else {