Skip to content

Commit

Permalink
Merge branch 'develop' into fix-intermittent-tests-fails
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy authored Oct 11, 2022
2 parents ca2c87f + 334ff90 commit cc5e26b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 55 deletions.
20 changes: 5 additions & 15 deletions tests/php/features/TestProtectedContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ public function testAdminNotOn() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query();

global $wp_the_query;
Expand All @@ -80,7 +78,7 @@ public function testAdminNotOn() {

$query->query( array() );

$this->assertTrue( empty( $this->fired_actions['ep_wp_query_search'] ) );
$this->assertNull( $query->elasticsearch_success );
}

/**
Expand All @@ -99,8 +97,6 @@ public function testAdminOn() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query();

global $wp_the_query;
Expand All @@ -109,7 +105,7 @@ public function testAdminOn() {

$wp_the_query->query( array() );

$this->assertTrue( ! empty( $this->fired_actions['ep_wp_query_search'] ) );
$this->assertTrue( $query->elasticsearch_success );
}

/**
Expand All @@ -129,8 +125,6 @@ public function testAdminOnDraft() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query();

global $wp_the_query;
Expand All @@ -143,7 +137,7 @@ public function testAdminOnDraft() {

$query->query( $args );

$this->assertTrue( ! empty( $this->fired_actions['ep_wp_query_search'] ) );
$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 1, $query->post_count );
$this->assertEquals( 1, $query->found_posts );
}
Expand Down Expand Up @@ -174,8 +168,6 @@ public function testAdminOnDraftUpdated() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query();

global $wp_the_query;
Expand All @@ -188,7 +180,7 @@ public function testAdminOnDraftUpdated() {

$query->query( $args );

$this->assertTrue( ! empty( $this->fired_actions['ep_wp_query_search'] ) );
$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 1, $query->post_count );
$this->assertEquals( 1, $query->found_posts );
}
Expand All @@ -211,8 +203,6 @@ public function testAdminCategories() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query();

global $wp_the_query;
Expand All @@ -230,7 +220,7 @@ public function testAdminCategories() {

$query->query( $args );

$this->assertTrue( ! empty( $this->fired_actions['ep_wp_query_search'] ) );
$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 2, $query->post_count );
$this->assertEquals( 2, $query->found_posts );
}
Expand Down
5 changes: 1 addition & 4 deletions tests/php/features/TestSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,13 @@ public function testSearchOn() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$args = array(
's' => 'findme',
);

$query = new \WP_Query( $args );

$this->assertTrue( ! empty( $this->fired_actions['ep_wp_query_search'] ) );
$this->assertTrue( $query->elasticsearch_success );
}

/**
Expand Down Expand Up @@ -367,4 +365,3 @@ public function testExcerptSetting() {
$this->assertTrue( $settings['highlight_excerpt'] );
}
}

16 changes: 4 additions & 12 deletions tests/php/features/TestWooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function tearDown() {
}

/**
* Test products post type query does get integrated when the feature is not active
* Test products post type query does get integrated when the feature is active
*
* @since 2.1
* @group woocommerce
Expand All @@ -73,8 +73,6 @@ public function testProductsPostTypeQueryOn() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$args = array(
'post_type' => 'product',
);
Expand All @@ -84,8 +82,6 @@ public function testProductsPostTypeQueryOn() {
$this->assertTrue( $query->elasticsearch_success );
$this->assertEquals( 1, $query->post_count );
$this->assertEquals( 1, $query->found_posts );

$this->assertTrue( ! empty( $this->fired_actions['ep_wp_query_search'] ) );
}

/**
Expand All @@ -103,8 +99,6 @@ public function testProductsPostTypeQueryProductCatTax() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$args = array(
'tax_query' => array(
array(
Expand Down Expand Up @@ -236,8 +230,6 @@ public function testSearchOnAllFrontEnd() {

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

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$args = array(
's' => 'findme',
'post_type' => 'product',
Expand All @@ -250,7 +242,7 @@ public function testSearchOnAllFrontEnd() {

/**
* Test the addition of variations skus to product meta
*
*
* @since 4.2.0
* @group woocommerce
*/
Expand Down Expand Up @@ -287,7 +279,7 @@ public function testAddVariationsSkusMeta() {

/**
* Test the translate_args_admin_products_list method
*
*
* @since 4.2.0
* @group woocommerce
*/
Expand Down Expand Up @@ -329,7 +321,7 @@ public function testTranslateArgsAdminProductsList() {

/**
* Test the ep_woocommerce_admin_products_list_search_fields filter
*
*
* @since 4.2.0
* @group woocommerce
*/
Expand Down
9 changes: 0 additions & 9 deletions tests/php/includes/classes/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ public function action_delete_post() {
$this->fired_actions['ep_delete_post'] = true;
}

/**
* Helper function to test whether a EP search has happened
*
* @since 1.0
*/
public function action_wp_query_search() {
$this->fired_actions['ep_wp_query_search'] = true;
}

/**
* Helper function to check post sync args
*
Expand Down
9 changes: 0 additions & 9 deletions tests/php/indexables/TestPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ public function testWPQuerySearchContent() {
's' => 'findme',
);

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query( $args );

$this->assertTrue( $query->elasticsearch_success );
Expand Down Expand Up @@ -251,8 +249,6 @@ public function testWPQuerySearchTitle() {
's' => 'findme',
);

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query( $args );

$this->assertTrue( $query->elasticsearch_success );
Expand Down Expand Up @@ -412,7 +408,6 @@ public function testPostTermSyncHierarchyMultipleLevelQuery() {
ElasticPress\Indexables::factory()->get( 'post' )->index( $post_id, true );
ElasticPress\Elasticsearch::factory()->refresh_indices();

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );
$query = new \WP_Query( array( 's' => '#findme' ) );

$this->assertTrue( $query->elasticsearch_success );
Expand Down Expand Up @@ -550,8 +545,6 @@ public function testWPQuerySearchExcerpt() {
's' => 'findme',
);

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query( $args );

$this->assertTrue( $query->elasticsearch_success );
Expand Down Expand Up @@ -3108,8 +3101,6 @@ public function testExcludeFromSearch() {
's' => 'findme',
);

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query( $args );

$this->assertTrue( $query->elasticsearch_success );
Expand Down
6 changes: 0 additions & 6 deletions tests/php/indexables/TestPostMultisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ public function testWPQuerySearchContent() {
'sites' => 'all',
);

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query( $args );

$this->assertTrue( $query->elasticsearch_success );
Expand Down Expand Up @@ -450,8 +448,6 @@ public function testWPQuerySearchTitle() {
'sites' => 'all',
);

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query( $args );

$this->assertTrue( $query->elasticsearch_success );
Expand Down Expand Up @@ -499,8 +495,6 @@ public function testWPQuerySearchExcerpt() {
'sites' => 'all',
);

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

$query = new \WP_Query( $args );

$this->assertTrue( $query->elasticsearch_success );
Expand Down

0 comments on commit cc5e26b

Please sign in to comment.