$npx -y skills add Lonsdale201/wp-agent-skills --skill bd-companion-pluginWork on better-data-plugin-test — the companion plugin
| 1 | # better-data: Companion plugin testbed |
| 2 | |
| 3 | For library maintainers working in the integration testbed at `wp-content/plugins/better-data-plugin-test/`. The plugin's job is to verify better-data behavior against real WordPress — things that pure unit tests can't reach (cache primings, `metadata_exists` semantics, `wp_slash` round-trips, REST schema actually appearing in `WP_REST_Server`, locale switching, encryption key constants). |
| 4 | |
| 5 | ## Misconception this skill corrects |
| 6 | |
| 7 | > "I'll add the new feature's integration test directly inside `better-data/tests/Unit/` so everything's in one place." |
| 8 | |
| 9 | Wrong. `tests/Unit/` is the **WP-free** zone — every test there must run with `composer test` against a clean PHP environment, no WP bootstrap, no MySQL. That's intentional: contributors can run the unit suite in seconds. WP-aware behavior goes in the companion plugin, where there's a real WordPress to talk to. |
| 10 | |
| 11 | The split: |
| 12 | |
| 13 | | Concern | Lives in | |
| 14 | |---|---| |
| 15 | | Pure type coercion, attribute reflection, builder logic | `better-data/tests/Unit/` | |
| 16 | | `wp_slash` round-trip, `metadata_exists` semantics, REST registration | `better-data-plugin-test/src/Smoke/` | |
| 17 | | Multi-step scenarios (encrypt → store → fetch → decrypt → reveal), edge-case discovery | `better-data-plugin-test/src/Stress/` | |
| 18 | | Visual confirmation (admin page renders `print_r($dto)`) | `better-data-plugin-test/src/Admin/` | |
| 19 | |
| 20 | Other AI-prone misconceptions: |
| 21 | |
| 22 | - "I'll let the plugin depend on WooCommerce since it makes the Order fixture realistic." Wrong — the plugin must run on a clean WP install with NOTHING but better-data. WC, ACF, custom-fields plugins are out. The Widget Shop fixture (`bd_widget` CPT + `bd_order` CPT + `ShopSettingsDto`) IS the realistic consumer because it's self-contained. |
| 23 | - "If a stress scenario is flaky, I'll mark it as `NOTE` instead of fixing it." Wrong — `NOTE` is for documented quirks the library legitimately surfaces (e.g. "WP serializes integer-keyed arrays as objects in some contexts"). A flaky test is a `FAIL` waiting to happen; fix it. |
| 24 | - "I'll move the new behavior into the library after the plugin verifies it." Wrong direction — integration-only behavior STAYS in the plugin. The library stays shape-agnostic. |
| 25 | |
| 26 | ## When to use this skill |
| 27 | |
| 28 | Trigger when ANY of the following is true: |
| 29 | |
| 30 | - The diff modifies any file under `wp-content/plugins/better-data-plugin-test/`. |
| 31 | - Adding a new smoke or stress scenario. |
| 32 | - Adding a new CLI subcommand under `bin/wp better-data <subcommand>`. |
| 33 | - Adding a new admin page, fixture DTO, or seed/purge routine. |
| 34 | - Reviewing a PR that adds WordPress / WC / ACF as a Composer dep on the plugin. |
| 35 | |
| 36 | ## Workflow |
| 37 | |
| 38 | ### 1. Three test tiers — pick the right one |
| 39 | |
| 40 | **Smoke — regression coverage.** |
| 41 | |
| 42 | ``` |
| 43 | src/Smoke/ |
| 44 | ├── Runner.php ← scenario list + dispatcher |
| 45 | └── Assertion.php ← per-scenario assertions |
| 46 | ``` |
| 47 | |
| 48 | Smoke scenarios run on every library change. They're short, focused, fast. A FAIL here means a regression — never ship over it. Add a smoke scenario for any new public behavior. |
| 49 | |
| 50 | **Stress — deep integration.** |
| 51 | |
| 52 | ``` |
| 53 | src/Stress/ |
| 54 | ├── Runner.php ← scenario list + dispatcher |
| 55 | └── Finding.php ← OK / FAIL / NOTE findings |
| 56 | ``` |
| 57 | |
| 58 | Stress scenarios are longer-running, multi-step, edge-case-hunting. They produce three outcomes: |
| 59 | |
| 60 | | Verdict | Meaning | |
| 61 | |---|---| |
| 62 | | `OK` | Library behaves as expected for this scenario | |
| 63 | | `FAIL` | Bug — blocks the change | |
| 64 | | `NOTE` | Discovery — library surfaces a quirk worth documenting (e.g. "PHP arrays with integer keys round-trip as JSON objects in this context") | |
| 65 | |
| 66 | `NOTE` is the unique value-add: it lets a stress run discover and SURFACE library limits witho |