Summary
Add and configure a PHPUnit-based test suite for the plugin, and add tests covering: (A) REST API performance and pagination behavior, and (B) snippet-ops functions (create/update/delete/import/export edge cases).
Goals
- Configure PHPUnit and the WordPress test harness so tests can run locally and in CI.
- Add unit/integration tests that assert REST API pagination headers, page contents, and out-of-range behavior.
- Add tests for
snippet-ops functions to increase coverage and guard against regressions.
- Add a lightweight performance test that asserts REST API responses meet a baseline latency under test conditions.
Tasks
Acceptance criteria
- PHPUnit runs locally and in CI (GitHub Actions) and returns green for the test suite.
- REST pagination tests reliably assert headers and per-page content differences.
snippet-ops tests cover the major create/update/delete/export/import flows and edge cases.
Notes / Implementation details
- The plugin already uses
WP_REST_Controller style controllers; prefer using rest_do_request() + WP_REST_Request in tests where possible to avoid network-dependant flakes.
- For performance tests, prefer a simple synthetic test that measures
rest_do_request() response time under a short loop instead of full HTTP requests; move to full HTTP tests only if necessary in E2E suite.
Environment / Setup
- Provide steps (or link to existing
tests/install.sh) for bootstrapping the WP test environment (WP test suite, DB, WP constants).
Please assign /cc whoever is best to implement the test infra and break this into smaller PRs if needed.
Summary
Add and configure a PHPUnit-based test suite for the plugin, and add tests covering: (A) REST API performance and pagination behavior, and (B)
snippet-opsfunctions (create/update/delete/import/export edge cases).Goals
snippet-opsfunctions to increase coverage and guard against regressions.Tasks
phpunit.xml(or update existing) with proper bootstrap and test suite configuration.tests/(phpunit):tests/RestApiTest.php— coversGET /code-snippets/v1/snippetspagination, headersX-WP-Total&X-WP-TotalPages, page contents differ, and out-of-range page behavior (empty array or 400 depending on API contract).tests/SnippetOpsTest.php— coverssnippet-opscreate/update/delete/export/import edge cases, invalid input handling, and permission checks.phpunit.ymlto run tests on PRs and master/core branch.Acceptance criteria
snippet-opstests cover the major create/update/delete/export/import flows and edge cases.Notes / Implementation details
WP_REST_Controllerstyle controllers; prefer usingrest_do_request()+WP_REST_Requestin tests where possible to avoid network-dependant flakes.rest_do_request()response time under a short loop instead of full HTTP requests; move to full HTTP tests only if necessary in E2E suite.Environment / Setup
tests/install.sh) for bootstrapping the WP test environment (WP test suite, DB, WP constants).Please assign /cc whoever is best to implement the test infra and break this into smaller PRs if needed.