test: REST PHPUnit tests#212
Conversation
There was a problem hiding this comment.
Pull request overview
Adds initial PHPUnit coverage for the REST layer in OneSearch, focusing on controller route registration, permission-sensitive behavior, and governing/consumer data flows. This fits the codebase by expanding unit coverage around the plugin’s cross-site REST integration points.
Changes:
- Adds new unit test files for the abstract REST controller and the main REST controllers/handler.
- Covers route registration, option reads/writes, brand config retrieval, indexable entities, and reindex behavior.
- Adds permission and origin/header checks for same-origin and cross-origin REST requests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
tests/php/Unit/Modules/Rest/Abstract_REST_ControllerTest.php |
Adds tests for hook registration, API permission checks, and host/origin matching. |
tests/php/Unit/Modules/Rest/Basic_Options_ControllerTest.php |
Adds tests for basic settings REST endpoints such as site type, shared sites, health check, and governing site. |
tests/php/Unit/Modules/Rest/Governing_Data_ControllerTest.php |
Adds tests for brand-config and all-post-types controller behavior across site types. |
tests/php/Unit/Modules/Rest/Governing_Data_HandlerTest.php |
Adds tests for governing-data fetch/caching, child-site post type retrieval, and cache clearing. |
tests/php/Unit/Modules/Rest/Search_ControllerTest.php |
Adds tests for search controller routes, Algolia credentials, indexable entities, and reindex behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
These test cases look really good - great job @Kallyan01 !
As noted, we want these to be outcome-focused integration tests and get as close to making real REST requests as possible instead of calling the controller methods directly, and gotta ditch the // ai slop comments everywhere. Once that's done it'l be easier to spot if there's something missing or more likely if there's some that are too "implementation-detail" focused that we want to ditch.
Either way, shouldn't take much before we can merge 🙌
…t classes and removed test file for Abstract_REST_Controller
…mline route registration
…ller across different site types
What
Added REST PHPUnit test cases.
Why
Improves development workflow by enabling faster and more reliable validation of REST functionality, reducing repetitive manual testing efforts.
Related Issue(s):
How
AI Disclosure
Hybrid approach = Written by Me + Copilot (Claude Opus 4.6, GPT 5.3) + Audited by me
Testing Instructions
Screenshots
Additional Info
Checklist