Skip to content

Commit

Permalink
Add test to NOT LIKE operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahmon committed Apr 5, 2021
1 parent 0c27d88 commit 6386d24
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/php/indexables/TestPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,36 @@ public function testMetaQueryLike() {
$this->assertEquals( 3, $query->found_posts );
}

/**
* Test a query that searches and filters by a meta value using NOT LIKE operator
*
* @since 3.6.0
* @group post
*/
public function testMetaQueryNotLike() {
Functions\create_and_sync_post( array( 'post_content' => 'post content findme' ), array( 'test_key' => 'ALICE in wonderland' ) );
Functions\create_and_sync_post( array( 'post_content' => 'post content findme' ), array( 'test_key' => 'alice in melbourne' ) );
Functions\create_and_sync_post( array( 'post_content' => 'post content findme' ), array( 'test_key' => 'AlicE in america' ) );

ElasticPress\Elasticsearch::factory()->refresh_indices();
$args = array(
's' => 'findme',
'meta_query' => array(
array(
'key' => 'test_key',
'value' => 'melbourne',
'compare' => 'NOT LIKE',
),
),
);

$query = new \WP_Query( $args );

$this->assertTrue( isset( $query->posts[0]->elasticsearch ) );
$this->assertEquals( 2, $query->post_count );
$this->assertEquals( 2, $query->found_posts );
}

/**
* Test meta queries with multiple keys
*/
Expand Down

0 comments on commit 6386d24

Please sign in to comment.