From 178eeaf57ef0938f488bd6b6ba521a723a9b0139 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 1 Jun 2020 19:41:50 +0000 Subject: [PATCH] Build/Test Tools: Let `WP_UnitTestCase_Base` extend the namespaced version of PHPUnit's test case class. With the minimum PHP version requirement set to 5.6 we're now able to use namespaces by default. This replaces `PHPUnit_Framework_TestCase` with `PHPUnit\Framework\TestCase` for `WP_UnitTestCase_Base` to solve autocompletion issues with code editors when using more recent PHPUnit versions. `PHPUnit\Framework\TestCase` is available since PHPUnit 5.4 and now the minimum required PHPUnit version. Fixes #50236. git-svn-id: https://develop.svn.wordpress.org/trunk@47880 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/abstract-testcase.php | 2 +- tests/phpunit/includes/bootstrap.php | 4 ++-- tests/phpunit/includes/functions.php | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index 8b1163a531..6cc2f5f022 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -12,7 +12,7 @@ require_once __DIR__ . '/trac.php'; * * All WordPress unit tests should inherit from this class. */ -abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase { +abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase { protected static $forced_tickets = array(); protected $expected_deprecated = array(); diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index dcde8fd2ea..d628d62c09 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -37,9 +37,9 @@ if ( ! is_readable( $config_file_path ) ) { require_once $config_file_path; require_once __DIR__ . '/functions.php'; -if ( version_compare( tests_get_phpunit_version(), '8.0', '>=' ) ) { +if ( version_compare( tests_get_phpunit_version(), '5.4', '<' ) || version_compare( tests_get_phpunit_version(), '8.0', '>=' ) ) { printf( - "Error: Looks like you're using PHPUnit %s. WordPress is currently only compatible with PHPUnit up to 7.x.\n", + "Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5.4 and is currently only compatible with PHPUnit up to 7.x.\n", tests_get_phpunit_version() ); echo "Please use the latest PHPUnit version from the 7.x branch.\n"; diff --git a/tests/phpunit/includes/functions.php b/tests/phpunit/includes/functions.php index e20114386a..dd80e887ce 100644 --- a/tests/phpunit/includes/functions.php +++ b/tests/phpunit/includes/functions.php @@ -10,8 +10,7 @@ function tests_get_phpunit_version() { if ( class_exists( 'PHPUnit_Runner_Version' ) ) { $version = PHPUnit_Runner_Version::id(); } elseif ( class_exists( 'PHPUnit\Runner\Version' ) ) { - // Must be parsable by PHP 5.2.x. - $version = call_user_func( 'PHPUnit\Runner\Version::id' ); + $version = PHPUnit\Runner\Version::id(); } else { $version = 0; }