Make WordPress Core

Changeset 49571

Timestamp:
11/12/2020 05:23:44 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Build/Test Tools: Only enforce PHP extension requirements when running core tests.

This allows other users of the WordPress unit test suite framework to run their own unit tests without needing the GD extension, which should only be a requirement if running core tests.

Follow-up to [49535].

Props jamescollins.
Fixes #50640.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/composer.json

    r49535 r49571  
    1717        "wp-coding-standards/wpcs": "~2.3.0",
    1818        "phpcompatibility/phpcompatibility-wp": "^2.1.0",
    19         "phpunit/phpunit": "^7.5",
    20         "ext-gd": "*"
     19        "phpunit/phpunit": "^7.5"
    2120    },
    2221    "autoload-dev": {
  • trunk/composer.lock

    r49535 r49571  
    55        "This file is @generated automatically"
    66    ],
    7     "content-hash": "fcf040d9233a22165eeffaeb98694436",
     7    "content-hash": "",
    88    "packages": [],
    99    "packages-dev": [
     
    131131                "constructor",
    132132                "instantiate"
    133             ],
    134             "funding": [
    135                 {
    136                     "url": "https://www.doctrine-project.org/sponsorship.html",
    137                     "type": "custom"
    138                 },
    139                 {
    140                     "url": "https://www.patreon.com/phpdoctrine",
    141                     "type": "patreon"
    142                 },
    143                 {
    144                     "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
    145                     "type": "tidelift"
    146                 }
    147133            ],
    148134            "time": "2020-05-29T17:27:14+00:00"
     
    18521838        "php": ">=5.6"
    18531839    },
    1854     "platform-dev": {
    1855         "ext-gd": "*"
    1856     },
     1840    "platform-dev": [],
    18571841    "plugin-api-version": "1.1.0"
    18581842}
  • trunk/tests/phpunit/includes/bootstrap.php

    r49570 r49571  
    5454}
    5555
    56 $required_extensions = array(
    57     'gd',
    58 );
    59 $missing_extensions  = array();
    60 
    61 foreach ( $required_extensions as $extension ) {
    62     if ( ! extension_loaded( $extension ) ) {
    63         $missing_extensions[] = $extension;
    64     }
    65 }
    66 
    67 if ( $missing_extensions ) {
    68     printf(
    69         "Error: The following required PHP extensions are missing from the testing environment: %s.\n",
    70         implode( ', ', $missing_extensions )
     56// If running core tests, check if all the required PHP extensions are loaded before running the test suite.
     57if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
     58    $required_extensions = array(
     59        'gd',
    7160    );
    72     echo "Please make sure they are installed and enabled.\n",
    73     exit( 1 );
     61    $missing_extensions  = array();
     62
     63    foreach ( $required_extensions as $extension ) {
     64        if ( ! extension_loaded( $extension ) ) {
     65            $missing_extensions[] = $extension;
     66        }
     67    }
     68
     69    if ( $missing_extensions ) {
     70        printf(
     71            "Error: The following required PHP extensions are missing from the testing environment: %s.\n",
     72            implode( ', ', $missing_extensions )
     73        );
     74        echo "Please make sure they are installed and enabled.\n",
     75        exit( 1 );
     76    }
    7477}
    7578
Note: See TracChangeset for help on using the changeset viewer.