Skip to content

test: REST PHPUnit tests#212

Open
Kallyan01 wants to merge 7 commits intomainfrom
test/rest-phpunit-tests
Open

test: REST PHPUnit tests#212
Kallyan01 wants to merge 7 commits intomainfrom
test/rest-phpunit-tests

Conversation

@Kallyan01
Copy link
Copy Markdown
Collaborator

@Kallyan01 Kallyan01 commented May 5, 2026

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

npm run wp-env:test -- start --xdebug=coverage    

npm run test:php -- tests/php/Unit/Modules/Rest

Screenshots

Additional Info

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • I have added necessary tests to cover my changes.
  • I have updated the project documentation as needed.
  • My code has detailed inline documentation.
  • My code is tested to the best of my abilities.
  • My code passes all lints, tests, and checks.
Open WordPress Playground Preview

@Kallyan01 Kallyan01 changed the title tests: REST PHPUnit tests test: REST PHPUnit tests May 5, 2026
@Kallyan01 Kallyan01 marked this pull request as ready for review May 5, 2026 16:26
Copilot AI review requested due to automatic review settings May 5, 2026 16:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/php/Unit/Modules/Rest/Governing_Data_ControllerTest.php
Comment thread tests/php/Unit/Modules/Rest/Governing_Data_ControllerTest.php
Comment thread tests/php/Unit/Modules/Rest/Governing_Data_HandlerTest.php Outdated
Comment thread tests/php/Unit/Modules/Rest/Governing_Data_HandlerTest.php Outdated
Comment thread tests/php/Unit/Modules/Rest/Governing_Data_HandlerTest.php Outdated
Comment thread tests/php/Unit/Modules/Rest/Governing_Data_HandlerTest.php Outdated
Comment thread tests/php/Unit/Modules/Rest/Governing_Data_HandlerTest.php Outdated
Comment thread tests/php/Unit/Modules/Rest/Search_ControllerTest.php Outdated
Comment thread tests/php/Unit/Modules/Rest/Abstract_REST_ControllerTest.php
Comment thread tests/php/Unit/Modules/Rest/Abstract_REST_ControllerTest.php Outdated
@Kallyan01 Kallyan01 requested review from justlevine May 5, 2026 17:27
@justlevine justlevine requested a review from sabbir1991 May 5, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants