Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy committed Mar 8, 2024
1 parent 6f9a143 commit 4434fbe
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/php/features/TestSynonyms.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,46 @@ public function test_synonyms_with_spaces() {
$this->assertTrue( $query->elasticsearch_success );
$this->assertSame( $post_id, $query->posts['0'] );
}

/**
* Tests synonyms are case insensitive
*
* @since 5.1.0
* @group synonyms
*/
public function testSynonymsCaseInsensitive() {
$instance = $this->getFeature();

$this->ep_factory->post->create(
[
'ID' => $instance->get_synonym_post_id(),
'post_content' => 'hoodie, sweatshirt',
'post_type' => $instance::POST_TYPE_NAME,
]
);

$instance->update_synonyms();

$post_id = $this->ep_factory->post->create( [ 'post_content' => 'sweatshirt' ] );

ElasticPress\Elasticsearch::factory()->refresh_indices();

$query = new \WP_Query(
[
's' => 'HoOdiE',
'fields' => 'ids',
]
);
$this->assertTrue( $query->elasticsearch_success );
$this->assertSame( $post_id, $query->posts['0'] );

$query = new \WP_Query(
[
's' => 'hoodie',
'fields' => 'ids',
]
);
$this->assertTrue( $query->elasticsearch_success );
$this->assertSame( $post_id, $query->posts['0'] );
}
}

0 comments on commit 4434fbe

Please sign in to comment.