wp-phpunit-writing-tests

Installation
SKILL.md

Writing WordPress PHPUnit tests

Once the harness is in place (wp-phpunit-test-setup), this skill is about the tests themselves: which base class, how to build fixtures, how to mock, and the integration-vs-unit decision that trips most people up.

When to use this skill

  • Writing the first real tests for a plugin/theme.
  • Reviewing tests for correct fixtures, isolation, and mocking.
  • Deciding between an integration test and a true unit test.
  • Mocking outbound HTTP (wp_remote_*) or WP functions.

Integration vs unit — get this right first

WP_UnitTestCase boots the full WordPress environment and uses a real test database. Its teardown and factory cleanup isolate normal WordPress records, but do not describe the suite as a universal per-test transaction: code that commits, creates tables/files, changes external services, starts cron workers, or mutates non-database globals still needs explicit cleanup. Despite the name, this is an integration test, not a pure unit test.

Installs
1
GitHub Stars
22
First Seen
1 day ago
wp-phpunit-writing-tests — lonsdale201/wp-agent-skills