diff --git a/tests/php/indexables/TestPost.php b/tests/php/indexables/TestPost.php index d70fe898c7..2b1e2b74de 100644 --- a/tests/php/indexables/TestPost.php +++ b/tests/php/indexables/TestPost.php @@ -3878,21 +3878,24 @@ public function testPrepareMetaManual() { // Set default weighting $weighting_default = $weighting->get_weighting_configuration_with_defaults(); + $set_default_weighting = function() use ( $weighting_default ) { return $weighting_default; }; + add_filter( 'ep_weighting_configuration', $set_default_weighting ); $post_id = $this->ep_factory->post->create( [ 'meta_input' => [ - 'test_meta_1' => 'value 1', - 'test_meta_2' => 'value 2', + 'test_meta_1' => 'value 1', + 'test_meta_2' => 'value 2', '_test_private_meta_1' => 'private value 1', '_test_private_meta_2' => 'private value 2', - ] + ], ] ); + $post = get_post( $post_id ); $prepared_meta = ElasticPress\Indexables::factory()->get( 'post' )->prepare_meta( $post ); @@ -8088,47 +8091,6 @@ public function testGetAllDistinctValues() { } /** - * Tests get_distinct_meta_field_keys_db - * - * @return void - * @group post - */ - public function testGetDistinctMetaFieldKeysDb() { - global $wpdb; - - $indexable = \ElasticPress\Indexables::factory()->get( 'post' ); - - $meta_keys = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} ORDER BY meta_key" ); - $this->assertSame( $meta_keys, $indexable->get_distinct_meta_field_keys_db() ); - - /** - * Test the `ep_post_pre_meta_keys_db` filter - */ - $return_custom_array = function() { - return [ 'totally_custom_key' ]; - }; - add_filter( 'ep_post_pre_meta_keys_db', $return_custom_array ); - - $num_queries = $wpdb->num_queries; - $this->assertGreaterThan( 0, $num_queries ); - - $this->assertSame( [ 'totally_custom_key' ], $indexable->get_distinct_meta_field_keys_db() ); - $this->assertSame( $num_queries, $wpdb->num_queries ); - - remove_filter( 'ep_post_pre_meta_keys_db', $return_custom_array ); - - /** - * Test the `ep_post_pre_meta_keys_db` filter - */ - $return_custom_array = function( $meta_keys ) { - return array_merge( $meta_keys, [ 'custom_key' ] ); - }; - add_filter( 'ep_post_meta_keys_db', $return_custom_array ); - - $this->assertSame( array_merge( $meta_keys, [ 'custom_key' ] ), $indexable->get_distinct_meta_field_keys_db() ); - } - - /* * Tests search term wrapped in html tags. */ public function testHighlightTags() {