From 9befeb00cc26673c61edaa34d43f680cc6e0efee Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 12 Nov 2020 17:23:44 +0000 Subject: [PATCH] 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 --- composer.json | 3 +-- composer.lock | 20 ++------------- tests/phpunit/includes/bootstrap.php | 37 +++++++++++++++------------- 3 files changed, 23 insertions(+), 37 deletions(-) diff --git a/composer.json b/composer.json index f2a9503e80..4997175bfe 100644 --- a/composer.json +++ b/composer.json @@ -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": [ diff --git a/composer.lock b/composer.lock index 14bdf41411..007bbf83ea 100644 --- a/composer.lock +++ b/composer.lock @@ -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" } diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index 8cfb86afbc..36f54541b2 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -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(