Skip to content

Commit

Permalink
Fix PHPCS issues. Remove redundant test.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakePT committed Sep 12, 2023
1 parent 0661a10 commit 3c5c48a
Showing 1 changed file with 6 additions and 44 deletions.
50 changes: 6 additions & 44 deletions tests/php/indexables/TestPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 3c5c48a

Please sign in to comment.