wp-cli/wp-cli-tests
WP-CLI testing framework for WP-CLI packages. Adds Composer scripts and tooling to run PHPUnit, Behat, PHPCS, and linting with optional cross-platform Behat config and custom PHPCS rulesets for consistent CI-ready testing.
composer require --dev wp-cli/wp-cli-tests. No Laravel-specific conflicts.phpunit, behat, lint) can coexist with Laravel’s phpunit.xml and phpunit config, but customization may be needed to avoid duplication.composer prepare-tests automates WordPress test DB setup, which is useful for WP-CLI commands but irrelevant for Laravel-only tests.behat.yml and feature files, adding setup overhead for non-WP projects.WP_CLI\Tests\Context\FeatureContext).phpunit.xml may need merging with WP-CLI’s defaults.Given/When/Then) valuable for our use case?behat.yml, phpcs.xml)?php artisan wp:command), this package enhances testing with Behat’s BDD and WP-specific contexts.| Laravel Component | WP-CLI Tests Fit | Notes |
|---|---|---|
| PHPUnit Tests | ✅ High | Reuse existing PHPUnit tests. |
| Pest Tests | ❌ Low | No native integration. |
| Behat/Gherkin | ✅ High (if WP needed) | Requires custom feature files. |
| Dusk/Browser Tests | ❌ N/A | Unrelated to CLI/WordPress. |
| Static Analysis (PHPStan) | ⚠️ Partial | PHPCS rules may conflict with Laravel’s. |
| WP-CLI Commands | ✅ Perfect | Designed for this. |
wp-cli/wp-cli-tests as a dev dependency:
composer require --dev wp-cli/wp-cli-tests
composer.json scripts (avoid duplication with Laravel’s phpunit).behat.yml and feature file.composer.json merge:
"scripts": {
"test": [
"phpunit", // Laravel's PHPUnit
"wp-cli-tests" // Custom script for Behat/PHPCS
],
"wp-cli-tests": [
"@prepare-tests",
"@phpunit",
"@behat"
],
"prepare-tests": "vendor/bin/wp-cli-tests install"
}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- run: composer install
- run: composer prepare-tests # WP-CLI DB setup
- run: composer test # Runs Laravel + WP-CLI tests
phpunit.xml but exclude WP-CLI-specific tests from Laravel’s suite.behat.yml (as per README).features/ directory.FeatureContext).phpcs.xml.WP_CLI_TEST_DBTYPE=sqlite for SQLite compatibility.composer prepare-tests reduces manual WordPress install steps.WP_VERSION) in tests.CONTRIBUTING.md.@skip-wordpress).How can I help you explore Laravel packages today?