| name | wordpress-phpunit-tests |
| description | Write PHPUnit unit or integration tests for a WordPress plugin class or method. Decides unit vs integration based on whether any WordPress function is called in the method's call chain — pure PHP uses Brain\Monkey + Mockery (unit); anything touching WordPress uses WP_UnitTestCase (integration). Use when asked to add or fix tests for changed PHP code in a WordPress plugin.
|
WordPress PHPUnit Tests
Write tests that follow the project's existing patterns precisely. Never invent a pattern when an
existing one already exists in the repo — read a comparable test first and mirror it.
This skill is vendor-neutral: test namespaces, base classes, config paths, and the base branch are
resolved per Project conventions, not hardcoded.
Project conventions (resolve before writing)
Resolve each in order, first hit wins:
AGENTS.md / CLAUDE.md — base branch, unit/integration base classes & namespaces,
PHPUnit config paths, stubs location, fixture/data-provider helper.
- Repo docs — testing/contributing notes.
- The code itself:
- Base branch →
git symbolic-ref refs/remotes/origin/HEAD, or the common develop/trunk/main.
- Base classes / namespaces → read an existing test under
tests/Unit and tests/Integration.
- PHPUnit config →
phpunit.xml*, tests/**/phpunit.xml*, or composer.json scripts.
- Stubs → an existing
tests/Unit/stubs/ (or equivalent) directory.
Before writing any tests