From addc32c145f33a1d91db74fb25419d14a3a4887b Mon Sep 17 00:00:00 2001 From: Brandon Kraft Date: Mon, 16 Mar 2026 18:28:55 -0500 Subject: [PATCH] Add practical PHP testing guidance to AGENTS.md Expand the PHP Testing section with details that AI agents need to correctly run and write tests: verbose/filter flags, WorDBless patterns, and the jp test vs jp docker distinction for plugins/jetpack. --- AGENTS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index c155275fcb67..3aedb10ae1c8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -130,11 +130,15 @@ jp test coverage # Generate coverage report (optional) ### PHP Testing +- `jp test php` works for all projects except `plugins/jetpack`, which uses `jp docker` commands +- Add `--verbose` for full output: `jp test php packages/connection --verbose` +- Filter to specific tests: `jp test php packages/connection --verbose -- --filter SSO_Test` - Use PHPUnit with WordPress test framework and `yoast/phpunit-polyfills` - Follow WordPress testing conventions, use WordPress fixtures and mocks - Test WordPress hooks and filters - Test class names MUST end in "Test" - Every test class MUST be in a file with a matching name (e.g., class `My_Unit_Test` in `My_Unit_Test.php`) +- Many packages use WorDBless (not the WP test factory). Test classes extend `WorDBless\BaseTestCase`. To create test users, use `wp_insert_user()` + `get_userdata()` — do NOT use `self::factory()->user->create_and_get()` as that method is not available. See `projects/packages/connection/tests/php/sso/Helpers_Test.php` for an example. See `docs/automated-testing.md` for full testing guidelines.