mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Build/Test Tools: Check if all the required PHP extensions are loaded before running the test suite.
Add the GD extension as a hard requirement. This improves the reliability of the test suite and ensures that if the test infrastructure changes in the future and a platform requirement such as GD accidentally gets removed, the tests fail with an appropriate error message. Follow-up to [48592]. Props ayeshrajans, jrf, johnbillion. Fixes #50640. git-svn-id: https://develop.svn.wordpress.org/trunk@49535 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a104c26283
commit
f2302a3112
@ -16,7 +16,8 @@
|
||||
"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"
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"ext-gd": "*"
|
||||
},
|
||||
"autoload-dev": {
|
||||
"files": [
|
||||
|
||||
20
composer.lock
generated
20
composer.lock
generated
@ -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": "463db2b4afb439fb63d93173c0852e27",
|
||||
"content-hash": "fcf040d9233a22165eeffaeb98694436",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
@ -131,6 +131,20 @@
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@ -1837,6 +1851,8 @@
|
||||
"platform": {
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"platform-dev": {
|
||||
"ext-gd": "*"
|
||||
},
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
||||
|
||||
@ -37,6 +37,11 @@ if ( ! is_readable( $config_file_path ) ) {
|
||||
require_once $config_file_path;
|
||||
require_once __DIR__ . '/functions.php';
|
||||
|
||||
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) {
|
||||
echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n";
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
$phpunit_version = tests_get_phpunit_version();
|
||||
|
||||
if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpunit_version, '8.0', '>=' ) ) {
|
||||
@ -48,8 +53,23 @@ if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpuni
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) {
|
||||
echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n";
|
||||
$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 )
|
||||
);
|
||||
echo "Please make sure they are installed and enabled.\n",
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
@ -59,17 +79,23 @@ $required_constants = array(
|
||||
'WP_TESTS_TITLE',
|
||||
'WP_PHP_BINARY',
|
||||
);
|
||||
$missing_constants = array();
|
||||
|
||||
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 );
|
||||
$missing_constants[] = $constant;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $missing_constants ) {
|
||||
printf(
|
||||
"Error: The following required constants are not defined: %s.\n",
|
||||
implode( ', ', $missing_constants )
|
||||
);
|
||||
echo "Please check out `wp-tests-config-sample.php` for an example.\n",
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
tests_reset__SERVER();
|
||||
|
||||
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user