-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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-opsfunctions 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
- Create
phpunit.xml(or update existing) with proper bootstrap and test suite configuration. - Add composer dev dependencies (phpunit, brain/brain or WP test helpers if needed) and document install steps.
- Add tests under
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.
-
- Add a GitHub Actions workflow
phpunit.ymlto run tests on PRs and master/core branch. - Document local setup and CI requirements in CONTRIBUTING.md or README (DB/WP test harness setup).
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-opstests cover the major create/update/delete/export/import flows and edge cases.
Notes / Implementation details
- The plugin already uses
WP_REST_Controllerstyle controllers; prefer usingrest_do_request()+WP_REST_Requestin 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request