← ClaudeAtlas

wp-plugin-testinglisted

Use when writing or setting up tests for a WordPress plugin — PHPUnit integration tests using WP_UnitTestCase with the WP test suite (bin/install-wp-tests.sh, phpunit.xml.dist, tests/bootstrap.php), unit tests with Brain Monkey (when() / expect() / Mockery) or WP_Mock, test factories (factory()->post->create(), ->user->create(), ->term->create()), HTTP request mocking with add_filter pre_http_request, AJAX testing with WP_Ajax_UnitTestCase, redirect/exit testing via exception-throwing pattern, multisite tests (WP_MULTISITE=1), acceptance tests with Codeception + wp-browser, or GitHub Actions CI matrix for PHP x WP versions. Triggers: "write a test for this", "unit test this function", "set up PHPUnit for my plugin", "mock this WP function", "Brain Monkey setup", "WP_Mock", "test is failing", "how do I test a hook", "test my REST endpoint", "factory()->post->create()", "install the WP test suite", "test my wp_mail call", "integration test setup", "bin/install-wp-tests.sh", "phpunit.xml.dist", "WP_UnitTestCase"
mralaminahamed/wp-dev-skills · ★ 27 · Testing & QA · score 77
Install: claude install-skill mralaminahamed/wp-dev-skills
# WordPress Plugin Testing > **Model note:** Bootstrap and CI config setup are mechanical (`haiku`). Writing meaningful test cases (choosing fixtures, mocking the right layer, testing edge cases) requires understanding the plugin's code — use `sonnet`. Redirect/exit harness setup is a one-time pattern and works on `haiku`. Set up and write automated tests for WordPress plugins: PHPUnit integration tests (real WP + DB), pure unit tests (no WP loaded), and acceptance/E2E tests with Codeception. ## When to use - "Set up PHPUnit tests for my plugin", "bootstrap a WP test suite", "scaffold plugin tests". - "Write a unit test for this function", "mock WordPress functions without loading WP". - "Set up Codeception / wp-browser", "write acceptance tests". - "Test a hook callback", "assert a filter changes the output", "test AJAX handlers". - "Add tests to CI", "run tests on GitHub Actions". **Not for:** PHPStan static analysis — use the official `wp-phpstan` skill. Scaffolding a stubs package for a third-party library — use `wp-phpstan-stubs`. Debugging CI failures on an existing suite — use `wp-ci-qa`. ## Method ### 1. Choose test type | Type | Tool | WP loaded | DB | Speed | |---|---|---|---|---| | Integration | PHPUnit + WP test suite (`WP_UnitTestCase`) | ✅ Full | ✅ Real (temp) | Slow | | Unit | PHPUnit + Brain\Monkey (recommended) or WP_Mock | ❌ | ❌ | Fast | | Acceptance | Codeception + wp-browser | ✅ Browser | ✅ Real | Slowest | Start with integration tests for hooks/f