Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Wp Cli Tests Laravel Package

wp-cli/wp-cli-tests

WP-CLI testing framework that bundles shared Behat, PHPUnit, PHP_CodeSniffer, and PHPStan tooling for WP-CLI commands and packages. Add it as a dev dependency to get ready-made test scripts, Behat feature contexts, and linting configs out of the box.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy for test infrastructure. Adopting this replaces a bespoke harness (WordPress provisioning, database setup, fixture files, HTTP mocking, assertion helpers, PHAR builds) with the harness the WP-CLI project itself uses. That is weeks of engineering effort we do not spend, for an MIT-licensed dev dependency. The decision is essentially "buy at zero price."
  • Whether a WP-CLI command package is worth building at all. The framework makes the marginal cost of adding a real functional test suite low, which changes the calculus on tooling projects that would otherwise be rejected as "untestable" — custom commands for migrations, content imports, multisite operations, deployment and cache workflows.
  • Roadmap sequencing for internal CLI tooling. Because functional tests become cheap, we can sequence smaller, more frequent CLI releases instead of batching risky changes. The behat-rerun and --stop-on-failure modes shorten the feedback loop, which supports a faster release cadence.
  • Support-matrix commitments. WP_VERSION (including latest, trunk, and pinned X.Y) and WP_CLI_TEST_CORE_ZIP let us decide, and then prove, which WordPress versions we support — including pre-release core builds. That turns "we support 6.x" from a claim into a test matrix, which is a pricing and support-contract input for hosting or agency offerings.
  • Quality-gate policy. The bundled scripts (lint, lint-gherkin, phpcs, phpstan, phpunit, behat) are individual, invokable gates. That lets us decide deliberately which gates are blocking on merge versus advisory, rather than inheriting an all-or-nothing pipeline.
  • Where to enforce standards. WP_CLI_CS plus feature-file scanning means code style and static analysis extend to the PHP embedded in Gherkin fixtures — a gap most teams never close, and a recurring source of broken example code in docs.
  • AI-assisted development policy. NO_COLOR and WP_CLI_TEST_QUIET exist specifically so output can be read back by tooling and coding agents, and the repo ships AGENTS.md guidance. That supports a decision to let agents run the narrowest relevant check (composer phpcs -- <file>, composer behat -- features/<name>.feature:<line>) rather than the full suite.
  • CI cost decisions. The docs are explicit that composer test installs WordPress from scratch per scenario and takes tens of minutes, needing jq, a MySQL/MariaDB client, and network access. That is a concrete input to CI budget: full suite on pull requests vs. on merge, with narrow checks during development.

When to Consider This Package

Adopt when most of the following hold:

  • We ship WP-CLI command packages (our own commands, or extensions to existing ones) and need confidence that commands behave correctly against a real WordPress installation, not mocks.
  • We want Given/When/Then functional tests where the vocabulary already exists: Given a WP install, Given these installed and active plugins:, When I run \wp ...``, Then STDOUT should be JSON containing:, exit-code assertions, table/CSV/YAML assertions, and HTTP mocking.
  • We need to test against multiple WordPress versions or unreleased core builds as part of a support commitment.
  • We want code style and static analysis applied to PHP snippets inside feature files, which generic PHP QA setups ignore.
  • We are willing to operate the infrastructure the suite assumes: a prepared MySQL/MariaDB test database, network access to WordPress.org, jq, and Node.js 20+ for the Gherkin linter.
  • We value aligning with the ecosystem's conventions — the WP_CLI\Tests\TestCase base class and the standard composer script names — over inventing our own.

Look elsewhere when:

  • The product is a Laravel, Symfony, or general PHP application. Nothing here applies; this is a WordPress/WP-CLI-specific harness. Standard PHPUnit/Pest is the answer.
  • We need broader WordPress plugin or theme testing (hooks, admin UI, template rendering). wp-env or wp-browser/Codeception cover more surface; this package is narrowly about commands and their I/O.
  • We need browser or end-to-end UI testing. Pair it with Playwright or similar; this will not do it.
  • CI cannot provide a database service, network egress to WordPress.org, or Node. The suite degrades here — notably lint-gherkin reports "skipping" rather than failing when npx is unavailable, which means a green build may hide a gate that never ran.
  • We only need unit tests. The framework's value is concentrated in the Behat/functional layer; for pure logic, plain PHPUnit is lighter.
  • We require a commercially supported, SLA-backed dependency. This is a low-visibility project (42 stars, MIT, no vendor support) maintained as part of WP-CLI's own tooling.

Adoption effort is genuinely small on the code side — composer require --dev, a scripts block, an optional behat.yml and phpcs.xml.dist, and one composer prepare-tests run. The real cost is CI plumbing and the wall-clock time of the functional suite, not integration.

Two caveats to weigh honestly: the reported 0 dependents almost certainly undercounts, because this is consumed as a dev dependency and therefore largely invisible to dependency graphs — the WP-CLI ecosystem does rely on it. Conversely, 42 stars and a small contributor base is a real concentration risk; mitigate by treating it as a versioned dev dependency we can fork if needed (MIT permits it), and by not letting its scripts become the only place our quality standards are defined.

How to Pitch It (Stakeholders)

For executives — one paragraph: We can add proper automated testing to our WordPress command-line tooling at effectively zero licence cost, using the same MIT-licensed test framework the official WP-CLI project uses internally. It replaces custom test scaffolding we would otherwise build and maintain, and it lets us state and verify which WordPress versions we support — including pre-release versions — which is directly relevant to support commitments and to any hosting or agency offering we price. The cost is a small integration effort and some CI time, not engineering headcount.

For engineering — the practical case: It ships the hard parts we would otherwise rewrite: Behat contexts that install and configure WordPress (single site, multisite subdirectory/subdomain, Composer-based installs, custom wp-content), fixtures and file assertions, STDOUT/STDERR format assertions (JSON, CSV, YAML, tables), HTTP mocking, PHAR build/download steps, and a WP_CLI\Tests\TestCase base class. It also enforces WP_CLI_CS and PHPStan over the PHP blocks embedded in feature files — a category of code that normally escapes review entirely. Everything is a discrete Composer script, so we choose our blocking gates. NO_COLOR and WP_CLI_TEST_QUIET make output machine-readable for CI logs and coding agents, and behat-rerun / --stop-on-failure / tag and line-number filtering keep the inner loop fast.

For engineering leadership — the risk framing: Pin the version and treat it as forkable. Budget for the CI environment it assumes (MySQL/MariaDB client with a prepared test database, jq, network access, Node 20+ if we want Gherkin linting), and expect the full suite to run in tens of minutes — run narrow checks per change and the full suite before merge. Note explicitly that a green composer test is not the same as a green CI, and that the Gherkin linter skips rather than fails when npx is missing; we should assert it actually ran.

The one-line version: Free, ecosystem-standard functional testing for our WordPress CLI tooling — adopt it to spend our engineering time on commands rather than on test plumbing.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
takashato/laravel-vietqr
aitor24/laralang
kraenzle-ritter/entity-relations
dindigital/din-image
pomirleanu/image-colors
sawmainek/laravel-api-generator
delatbabel/jsonresponses
mouhamedfd/permissions-generator
eduplus/qr
laravel2580/idehelpers
delatbabel/viewpages
anavel/gettext
muhamadrezaar/highcharts
delatbabel/keylists
frankkessler/salesforce-laravel-oauth2-rest
anavel/foundation
wdmtech/enviricons
eii/laravel-captcha
muka/shape-reader
tdt/json