Skip to content

Commit 9befeb0

Browse files
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
1 parent f717424 commit 9befeb0

3 files changed

Lines changed: 21 additions & 35 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7.0",
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": {
2322
"files": [

composer.lock

Lines changed: 2 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/phpunit/includes/bootstrap.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,27 @@
5353
exit( 1 );
5454
}
5555

56-
$required_extensions = array(
57-
'gd',
58-
);
59-
$missing_extensions = array();
56+
// If running core tests, check if all the required PHP extensions are loaded before running the test suite.
57+
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
58+
$required_extensions = array(
59+
'gd',
60+
);
61+
$missing_extensions = array();
6062

61-
foreach ( $required_extensions as $extension ) {
62-
if ( ! extension_loaded( $extension ) ) {
63-
$missing_extensions[] = $extension;
63+
foreach ( $required_extensions as $extension ) {
64+
if ( ! extension_loaded( $extension ) ) {
65+
$missing_extensions[] = $extension;
66+
}
6467
}
65-
}
6668

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 )
71-
);
72-
echo "Please make sure they are installed and enabled.\n",
73-
exit( 1 );
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

7679
$required_constants = array(

0 commit comments

Comments
 (0)