Skip to content

Commit a3bd118

Browse files
committed
Build/Test Tools: Allow the desired version of PHPUnit to be passed to the local Docker environment.
This change introduces the `LOCAL_PHPUNIT` environment variable that allows the desired version of PHPUnit to be specified when running the PHP tests within the local Docker environment. Because support for newer versions of PHPUnit is not backported, some versions of PHP need the ability to run multiple versions of PHPUnit for different branches. This adds the flexibility needed to use the Docker environment within those older branches to run the PHP tests. Props johnbillion. Fixes #50042. git-svn-id: https://develop.svn.wordpress.org/trunk@49358 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 72a37d4 commit a3bd118

7 files changed

Lines changed: 52 additions & 18 deletions

File tree

.env

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#
44
# All of these options can be overridden by setting them as environment variables before starting
55
# the environment. You will need to restart your environment when changing any of these.
6+
#
7+
# Below, the following substitutions can be made:
8+
# - '{version}': any major.minor PHP version from 5.2 onwards.
9+
# - '{phpunit_version}': any major PHPUnit version starting with 4.
610
##
711

812
# The site will be available at http://localhost:LOCAL_PORT
@@ -11,10 +15,30 @@ LOCAL_PORT=8889
1115
# Where to run WordPress from. Valid options are 'src' and 'build'.
1216
LOCAL_DIR=src
1317

14-
# The PHP version to use. Valid options are 'latest', and '{version}-fpm', where '{version}' is any
15-
# x.y PHP version from 5.2 onwards.
18+
# The PHP version to use. Valid options are 'latest', and '{version}-fpm'.
1619
LOCAL_PHP=latest
1720

21+
##
22+
# The PHPUnit version to use when running tests.
23+
#
24+
# Support for new PHPUnit versions is not backported to past versions, so some old WordPress branches require an older
25+
# version to run tests.
26+
#
27+
# Valid versions are:
28+
# - 'latest' for the highest version of PHPUnit supported on the highest version of PHP supported.
29+
# - '{version}-fpm' for the highest version of PHPUnit supported on the specified version of PHP.
30+
# - '{phpunit_version}-php-{version}-fpm' for a specific version of PHPUnit on the specified version of PHP. This format
31+
# is only available for PHP versions 5.6 and higher.
32+
#
33+
# For the full list of available options, see https://hub.docker.com/r/wordpressdevelop/phpunit/tags.
34+
#
35+
# For full documentation on PHPUnit compatibility and WordPress versions, see
36+
# https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/.
37+
#
38+
# This defaults to the value assigned to the value of LOCAL_PHP.
39+
##
40+
LOCAL_PHPUNIT=${LOCAL_PHP}
41+
1842
# Whether or not to enable XDebug.
1943
LOCAL_PHP_XDEBUG=false
2044

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ services:
9696
# The PHPUnit container.
9797
##
9898
phpunit:
99-
image: wordpressdevelop/phpunit:${LOCAL_PHP-latest}
99+
image: wordpressdevelop/phpunit:${LOCAL_PHPUNIT-latest}
100100

101101
networks:
102102
- wpdevnet

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"check-node-version": "4.0.1",
3636
"copy-webpack-plugin": "^5.1.1",
3737
"cssnano": "4.1.10",
38-
"dotenv": "8.1.0",
38+
"dotenv": "8.2.0",
3939
"dotenv-expand": "5.1.0",
4040
"grunt": "~1.1.0",
4141
"grunt-banner": "^0.6.0",

tools/local-env/scripts/docker.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const dotenv = require( 'dotenv' );
1+
const dotenv = require( 'dotenv' );
2+
const dotenvExpand = require( 'dotenv-expand' );
23
const { execSync } = require( 'child_process' );
3-
dotenv.config();
4+
5+
dotenvExpand( dotenv.config() );
46

57
// Execute any docker-compose command passed to this script.
68
execSync( 'docker-compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } );

tools/local-env/scripts/install.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const dotenv = require( 'dotenv' );
1+
const dotenv = require( 'dotenv' );
2+
const dotenvExpand = require( 'dotenv-expand' );
23
const wait_on = require( 'wait-on' );
34
const { execSync } = require( 'child_process' );
45
const { renameSync, readFileSync, writeFileSync } = require( 'fs' );
56

6-
dotenv.config();
7+
dotenvExpand( dotenv.config() );
78

89
// Create wp-config.php.
910
wp_cli( 'config create --dbname=wordpress_develop --dbuser=root --dbpass=password --dbhost=mysql --path=/var/www/src --force' );

tools/local-env/scripts/start.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const dotenv = require( 'dotenv' );
1+
const dotenv = require( 'dotenv' );
2+
const dotenvExpand = require( 'dotenv-expand' );
23
const { execSync } = require( 'child_process' );
34

4-
dotenv.config();
5+
dotenvExpand( dotenv.config() );
56

67
// Start the local-env containers.
78
execSync( 'docker-compose up -d wordpress-develop', { stdio: 'inherit' } );

0 commit comments

Comments
 (0)