WordPress.org

Make WordPress Core

Changeset 48592


Ignore:
Timestamp:
07/23/2020 11:26:50 PM (2 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r48532 r48592  
    3838require_once __DIR__ . '/functions.php';
    3939
    40 if ( version_compare( tests_get_phpunit_version(), '5.4', '<' ) || version_compare( tests_get_phpunit_version(), '8.0', '>=' ) ) {
     40$phpunit_version = tests_get_phpunit_version();
     41
     42if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpunit_version, '8.0', '>=' ) ) {
    4143    printf(
    4244        "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",
    43         tests_get_phpunit_version()
     45        $phpunit_version
    4446    );
    4547    echo "Please use the latest PHPUnit version from the 7.x branch.\n";
     
    5052    echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n";
    5153    exit( 1 );
     54}
     55
     56$required_constants = array(
     57    'WP_TESTS_DOMAIN',
     58    'WP_TESTS_EMAIL',
     59    'WP_TESTS_TITLE',
     60    'WP_PHP_BINARY',
     61);
     62
     63foreach ( $required_constants as $constant ) {
     64    if ( ! defined( $constant ) ) {
     65        printf(
     66            "Error: The required %s constant is not defined. Check out `wp-tests-config-sample.php` for an example.\n",
     67            $constant
     68        );
     69        exit( 1 );
     70    }
    5271}
    5372
Note: See TracChangeset for help on using the changeset viewer.