This document explains the testing matrix configuration for the WP Multi-Network plugin, which ensures compatibility across multiple versions of WordPress, PHP, and PHPUnit.
The testing matrix is designed to validate the plugin against various combinations of:
- WordPress versions: 5.5 (minimum) through latest
- PHP versions: 7.2 (minimum) through 8.3
- PHPUnit versions: 7, 8, and 9
| PHPUnit Version | PHP Requirement | WordPress Compatibility | Configuration File |
|---|---|---|---|
| PHPUnit 9.x | PHP 7.3+ | All versions | phpunit.xml.dist |
| PHPUnit 8.x | PHP 7.2+ | All versions | phpunit.xml.legacy |
| PHPUnit 7.x | PHP 7.1+ | WP 4.9 - 6.x | phpunit.xml.legacy |
| WordPress Version | Minimum PHP | Recommended PHP |
|---|---|---|
| trunk | 7.2.24 | 8.0+ |
| 6.4 - 6.9 | 7.2.24 | 8.0+ |
| 6.0 - 6.3 | 7.2.24 | 7.4+ |
| 5.9 | 7.2.24 | 7.4+ |
| 5.5 - 5.8 | 7.2.0 | 7.4+ |
The GitHub Actions workflow (.github/workflows/phpunit-ci.yml) runs tests across the following combinations:
- PHP 8.3 + PHPUnit 9
- PHP 8.3 + PHPUnit 9
- PHP 8.2 + PHPUnit 9
- PHP 8.3 + PHPUnit 9
- PHP 8.2 + PHPUnit 9
- PHP 8.1 + PHPUnit 9
- PHP 8.3 + PHPUnit 9
- PHP 8.2 + PHPUnit 9
- PHP 8.1 + PHPUnit 9
- PHP 8.0 + PHPUnit 9
- PHP 8.3 + PHPUnit 9 (WP 6.6)
- PHP 8.2 + PHPUnit 9 (WP 6.5)
- PHP 8.1 + PHPUnit 9 (WP 6.4)
- PHP 8.0 + PHPUnit 9 (WP 6.3)
- PHP 7.4 + PHPUnit 9 (WP 6.2)
- PHP 7.4 + PHPUnit 9 (WP 6.1)
- PHP 7.4 + PHPUnit 9 (WP 6.0)
- PHP 7.4 + PHPUnit 9
- PHP 7.3 + PHPUnit 9
- PHP 7.2 + PHPUnit 8
- PHP 7.2 + PHPUnit 8
-
Install dependencies:
composer install
-
Set up the WordPress test environment:
bash bin/install-wp-tests.sh wordpress_test wp wp localhost latest
Parameters:
wordpress_test: Database namewp: Database userwp: Database passwordlocalhost: Database hostlatest: WordPress version (or specific version like6.4)
With PHPUnit 9 (default):
./vendor/bin/phpunitWith PHPUnit 8 (using legacy config):
composer require --dev phpunit/phpunit:^8.5
./vendor/bin/phpunit --configuration phpunit.xml.legacyWith specific WordPress version:
export WP_VERSION=6.4
bash bin/install-wp-tests.sh wordpress_test wp wp localhost $WP_VERSION
./vendor/bin/phpunitTests are organized using PHPUnit groups for easy filtering:
Run all upload path tests:
./vendor/bin/phpunit --group=uploadRun tests by ticket number:
./vendor/bin/phpunit --group=136Run specific test groups:
# Files rewriting tests
./vendor/bin/phpunit --group=files-rewriting
# Multisite configuration tests
./vendor/bin/phpunit --group=multisite
# Subdirectory installation tests
./vendor/bin/phpunit --group=subdirectoryRun a single test class:
./vendor/bin/phpunit tests/integration/tests/test-upload-paths.phpRun a specific test method:
./vendor/bin/phpunit --filter test_upload_path_without_duplicationVerbose and debug output:
./vendor/bin/phpunit --group=upload --verbose
./vendor/bin/phpunit --group=upload --debugYou can test different PHP versions using Docker:
# PHP 8.3
docker run --rm -v $(pwd):/app -w /app php:8.3-cli bash -c "composer install && ./vendor/bin/phpunit"
# PHP 8.0
docker run --rm -v $(pwd):/app -w /app php:8.0-cli bash -c "composer install && ./vendor/bin/phpunit"
# PHP 7.4
docker run --rm -v $(pwd):/app -w /app php:7.4-cli bash -c "composer install && ./vendor/bin/phpunit"Modern PHPUnit configuration with:
- Updated XML schema for PHPUnit 9.6
<coverage>element for code coverage- Removed deprecated attributes (
convertErrorsToExceptions,syntaxCheck, etc.)
Legacy PHPUnit configuration with:
- XML schema for PHPUnit 8.5
<filter><whitelist>for code coverage<logging>element for reports- Preserved deprecated attributes for compatibility
The test bootstrap (tests/integration/includes/bootstrap.php) automatically:
- Detects the WordPress test suite location via
WP_TESTS_DIRorWP_DEVELOP_DIR - Loads the plugin before WordPress initializes
- Sets up multisite testing environment
The GitHub Actions workflow automatically:
- Sets up the specified PHP version
- Installs the appropriate PHPUnit version
- Installs the WordPress test suite
- Selects the correct PHPUnit configuration file
- Runs the test suite
- Reports results
The workflow uses fail-fast: false to ensure all matrix jobs run even if one fails, providing comprehensive test coverage feedback.
If you encounter version conflicts:
# Remove existing PHPUnit
composer remove --dev phpunit/phpunit
# Install specific version
composer require --dev phpunit/phpunit:^9.6Ensure WP_TESTS_DIR is set correctly:
export WP_TESTS_DIR=/tmp/wordpress-tests-lib
bash bin/install-wp-tests.sh wordpress_test wp wp localhost latestVerify your database credentials:
mysql -u wp -pwp -e "CREATE DATABASE IF NOT EXISTS wordpress_test;"To add support for new WordPress, PHP, or PHPUnit versions:
- Update the matrix in
.github/workflows/phpunit-ci.yml - Add a new entry under
matrix.include - Ensure PHPUnit version compatibility with PHP version
- Test locally before committing
Example:
- wordpress: "6.8"
php: "8.4"
phpunit: "9"
wp-version: "6.8"- Always test locally before pushing to ensure tests pass
- Keep PHPUnit versions up to date within compatibility constraints
- Test edge cases with minimum and maximum supported versions
- Monitor WordPress releases for new compatibility requirements
- Update documentation when changing test configurations