Test a WordPress plugin using PHPUnit.
This action tests a WordPress plugin in a environment that is similar to a real WordPress site. It installs WordPress, activates the plugin, and runs the tests. Read more about the WordPress plugin integration test.
The action installs the specified PHP version and extensions, installs WordPress, installs development dependencies, and runs PHPUnit tests.
WordPress plugin integration tests usually require PHPUnit-Polyfills to run, so you probably want to specify the version of PHPUnit-Polyfills to install in your composer.json file.
- uses: holyhope/test-wordpress-plugin-github-action@main
with:
# Description: WordPress version
#
# Default: latest
wordpress_version: ""
# Description: PHP version
#
# Default: 8.2
php_version: ""
# Description: PHP extensions to install. Each extension should be on a new line.
#
# Default: imagick
php_extensions: ""
# Description: Path to the WordPress plugin
#
# Default: .
plugin_dir: ""
# Description: Slug of the WordPress plugin
#
plugin_slug: ""
# Description: PHPUnit version to install.
#
# Set to `false` to use the system-wide PHPUnit binary.
#
# Default: Install the version found in `composer.json` file or `^9` if not found.
#
# Default: ^9
phpunit_version: ""
# Description: PHPUnit configuration file
#
# Default: phpunit.xml
phpunit_config: ""
# Description: Generates files needed for running PHPUnit tests in a plugin.
#
# Default: true
scaffold_tests: ""| Input | Description | Default | Required |
|---|---|---|---|
wordpress_version |
WordPress version | latest |
false |
php_version |
PHP version | 8.2 |
false |
php_extensions |
PHP extensions to install. Each extension should be on a new line. |
imagick |
false |
plugin_dir |
Path to the WordPress plugin | . |
false |
plugin_slug |
Slug of the WordPress plugin | true | |
phpunit_version |
PHPUnit version to install. | ^9 |
false |
phpunit_config |
PHPUnit configuration file | phpunit.xml |
false |
scaffold_tests |
Generates files needed for running PHPUnit tests in a plugin. | true |
false |
| Output | Description |
|---|---|
junit_report |
Path to the JUnit report |