Write PHPUnit tests for a WordPress plugin or theme. Covers the integration base class WP_UnitTestCase and its snake_case set_up() / tear_down() fixtures (and why WordPress uses them via phpunit-polyfills), the per-test DB transaction rollback, the factory system (self::factory()->post->create(), create_many(), create_and_get(), wpSetUpBeforeClass()), WP assertions (assertWPError, assertEqualSets), HTTP mocking with the pre_http_request filter, data providers and @group, and the crucial distinction that WP_UnitTestCase is an INTEGRATION test (real WP + DB) while true unit tests need Brain Monkey or WP_Mock to mock WP functions. Use when authoring or reviewing tests, choosing unit vs integration, mocking HTTP/WP functions, or fixing fixture/factory mistakes. For scaffolding and CI see wp-phpunit-test-setup.
$npx -y skills add lonsdale201/wp-agent-skills --skill wp-phpunit-writing-testsInstalls into the current project.
Run `npx skills use "https://github.com/lonsdale201/wp-agent-skills" --skill "lonsdale201/wp-agent-skills/wp-phpunit-writing-tests"` and follow the generated skill instructions now. Read its complete output, redirecting it to a temporary file first if necessary. Resolve relative paths from the supporting-files directory it provides.
Use the skills in "https://github.com/lonsdale201/wp-agent-skills" that are relevant to the current task. Run `npx skills add "https://github.com/lonsdale201/wp-agent-skills"` and select the relevant skills, then follow their instructions.