Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for site__in and site__not_in parameters #2991

Merged
merged 10 commits into from
Oct 11, 2022
Prev Previous commit
Next Next commit
Fix linting
  • Loading branch information
burhandodhy committed Sep 20, 2022
commit 0f184a1bad2f5e8ed1337305f8717b07d47c0e71
57 changes: 36 additions & 21 deletions tests/php/indexables/TestCommentMultisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ public function testCommentQueryForAllSites() {
restore_current_blog();
}

$query = new \WP_Comment_Query( array(
'ep_integrate' => true,
'site__in' => 'all'
) );
$query = new \WP_Comment_Query(
array(
'ep_integrate' => true,
'site__in' => 'all',
)
);

$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 9, count( $query->get_comments() ) );
Expand Down Expand Up @@ -135,10 +137,12 @@ public function testCommentQueryForSitesSubset() {
restore_current_blog();
}

$query = new \WP_Comment_Query( array(
'ep_integrate' => true,
'site__in' => [ $sites[0]['blog_id'], $sites[2]['blog_id'] ]
) );
$query = new \WP_Comment_Query(
array(
'ep_integrate' => true,
'site__in' => array( $sites[0]['blog_id'], $sites[2]['blog_id'] ),
)
);

$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 6, count( $query->get_comments() ) );
Expand Down Expand Up @@ -170,10 +174,12 @@ public function testCommentQueryForSitesExceptOne() {
restore_current_blog();
}

$query = new \WP_Comment_Query( array(
'ep_integrate' => true,
'site__not_in' => [ $sites[2]['blog_id'] ]
) );
$query = new \WP_Comment_Query(
array(
'ep_integrate' => true,
'site__not_in' => array( $sites[2]['blog_id'] ),
)
);

$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 6, count( $query->get_comments() ) );
Expand All @@ -199,16 +205,23 @@ public function testCommentQuerySearchForAllSites() {

$this->ep_factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$this->ep_factory->comment->create( array( 'comment_post_ID' => $post_id ) );
$this->ep_factory->comment->create( array( 'comment_post_ID' => $post_id, 'comment_content' => 'Hello World' ) );
$this->ep_factory->comment->create(
array(
'comment_post_ID' => $post_id,
'comment_content' => 'Hello World',
)
);

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

$query = new \WP_Comment_Query( array(
'search' => 'Hello World',
'site__in' => 'all'
) );
$query = new \WP_Comment_Query(
array(
'search' => 'Hello World',
'site__in' => 'all',
)
);

$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 3, count( $query->get_comments() ) );
Expand Down Expand Up @@ -241,10 +254,12 @@ public function testCommentQueryWithDeprecatedSitesParam() {
restore_current_blog();
}

$query = new \WP_Comment_Query( array(
'ep_integrate' => true,
'sites' => 'all'
) );
$query = new \WP_Comment_Query(
array(
'ep_integrate' => true,
'sites' => 'all',
)
);

$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 9, count( $query->get_comments() ) );
Expand Down