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.

git-svn-id: https://develop.svn.wordpress.org/trunk@49571 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-11-12 17:23:44 +00:00
parent f717424287
commit 9befeb00cc
3 changed files with 23 additions and 37 deletions

View File

@ -16,8 +16,7 @@
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7.0",
"wp-coding-standards/wpcs": "~2.3.0",
"phpcompatibility/phpcompatibility-wp": "^2.1.0",
"phpunit/phpunit": "^7.5",
"ext-gd": "*"
"phpunit/phpunit": "^7.5"
},
"autoload-dev": {
"files": [

20
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "fcf040d9233a22165eeffaeb98694436",
"content-hash": "463db2b4afb439fb63d93173c0852e27",
"packages": [],
"packages-dev": [
{
@ -131,20 +131,6 @@
"constructor",
"instantiate"
],
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
"type": "tidelift"
}
],
"time": "2020-05-29T17:27:14+00:00"
},
{
@ -1851,8 +1837,6 @@
"platform": {
"php": ">=5.6"
},
"platform-dev": {
"ext-gd": "*"
},
"platform-dev": [],
"plugin-api-version": "1.1.0"
}

View File

@ -53,24 +53,27 @@ if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpuni
exit( 1 );
}
$required_extensions = array(
'gd',
);
$missing_extensions = array();
foreach ( $required_extensions as $extension ) {
if ( ! extension_loaded( $extension ) ) {
$missing_extensions[] = $extension;
}
}
if ( $missing_extensions ) {
printf(
"Error: The following required PHP extensions are missing from the testing environment: %s.\n",
implode( ', ', $missing_extensions )
// If running core tests, check if all the required PHP extensions are loaded before running the test suite.
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
$required_extensions = array(
'gd',
);
echo "Please make sure they are installed and enabled.\n",
exit( 1 );
$missing_extensions = array();
foreach ( $required_extensions as $extension ) {
if ( ! extension_loaded( $extension ) ) {
$missing_extensions[] = $extension;
}
}
if ( $missing_extensions ) {
printf(
"Error: The following required PHP extensions are missing from the testing environment: %s.\n",
implode( ', ', $missing_extensions )
);
echo "Please make sure they are installed and enabled.\n",
exit( 1 );
}
}
$required_constants = array(