Build/Test Tools: Check if all the required constants are defined before running the test suite.

Follow-up to [47904].

Props azaozz, TimothyBlynJacobs, SergeyBiryukov.
Fixes #50251.

git-svn-id: https://develop.svn.wordpress.org/trunk@48592 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-07-23 23:26:50 +00:00
parent b932c543a2
commit 1ef40b14cd

View File

@ -37,10 +37,12 @@ if ( ! is_readable( $config_file_path ) ) {
require_once $config_file_path;
require_once __DIR__ . '/functions.php';
if ( version_compare( tests_get_phpunit_version(), '5.4', '<' ) || version_compare( tests_get_phpunit_version(), '8.0', '>=' ) ) {
$phpunit_version = tests_get_phpunit_version();
if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpunit_version, '8.0', '>=' ) ) {
printf(
"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()
$phpunit_version
);
echo "Please use the latest PHPUnit version from the 7.x branch.\n";
exit( 1 );
@ -51,6 +53,23 @@ if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH )
exit( 1 );
}
$required_constants = array(
'WP_TESTS_DOMAIN',
'WP_TESTS_EMAIL',
'WP_TESTS_TITLE',
'WP_PHP_BINARY',
);
foreach ( $required_constants as $constant ) {
if ( ! defined( $constant ) ) {
printf(
"Error: The required %s constant is not defined. Check out `wp-tests-config-sample.php` for an example.\n",
$constant
);
exit( 1 );
}
}
tests_reset__SERVER();
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );