Skip to content

test: Search PHPUnit tests#213

Open
Kallyan01 wants to merge 8 commits intomainfrom
test/search-phpunit-tests
Open

test: Search PHPUnit tests#213
Kallyan01 wants to merge 8 commits intomainfrom
test/search-phpunit-tests

Conversation

@Kallyan01
Copy link
Copy Markdown
Collaborator

@Kallyan01 Kallyan01 commented May 8, 2026

What

Why

Related Issue(s):

How

AI Disclosure

Testing Instructions

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

Copilot AI review requested due to automatic review settings May 8, 2026 06:21
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

This PR adds PHPUnit unit tests for the Search module’s WordPress integration points and for the Algolia Index wrapper, helping validate hook registration and several “remote post” mapping behaviors.

Changes:

  • Add SearchTest covering hook registration and selected behaviors for permalinks, author fields, term links, and rendered block rewriting.
  • Add IndexTest covering error returns when prerequisites are missing and verifying Index::get_index() caching behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
tests/php/Unit/Modules/Search/SearchTest.php Introduces unit tests for OneSearch\Modules\Search\Search behaviors (hooks, mapping, block output).
tests/php/Unit/Modules/Search/IndexTest.php Introduces unit tests for OneSearch\Modules\Search\Index error handling and caching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/php/Unit/Modules/Search/SearchTest.php Outdated
Comment thread tests/php/Unit/Modules/Search/SearchTest.php
Comment thread tests/php/Unit/Modules/Search/SearchTest.php Outdated
Comment thread tests/php/Unit/Modules/Search/SearchTest.php
Comment thread tests/php/Unit/Modules/Search/IndexTest.php
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread tests/php/Unit/Modules/Search/SettingsTest.php
Comment on lines +134 to +153
* The delete still attempts (and fails without creds), but the reindex does not happen.
*/
public function test_on_post_transition_does_not_reindex_disallowed_status(): void {
update_option( Settings::OPTION_SITE_TYPE, Settings::SITE_TYPE_GOVERNING );
update_option(
Search_Settings::OPTION_GOVERNING_INDEXABLE_SITES,
[
'entities' => [
Utils::normalize_url( get_site_url() ) => [ 'post' ],
],
]
);

$post = self::factory()->post->create_and_get( [ 'post_status' => 'publish' ] );
$watcher = new Watcher();

// Transitioning to 'trash' — should not reindex (only delete).
$watcher->on_post_transition( 'trash', 'publish', $post );

$this->assertTrue( true );
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