Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy committed Aug 12, 2024
1 parent b535cfe commit 994f09c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/php/features/TestFacet.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,34 @@ public function test_get_settings_schema() {
);
}

/**
* Test ep_facet_selected_filters filter.
*
* @since 5.2.0
* @group facets
*/
public function test_ep_facet_selected_filters() {
$facet_feature = Features::factory()->get_registered_feature( 'facets' );

parse_str( 'ep_filter_taxonomy=dolor,sit', $_GET );

$add_prefix_with_term = function( $filter ) {
$new_terms = [];
foreach ( $filter['taxonomies']['taxonomy']['terms'] as $key => $value ) {
$new_terms[ 'cap-' . $key ] = $value;
}

$filter['taxonomies']['taxonomy']['terms'] = $new_terms;
return $filter;
};
add_filter( 'ep_facet_selected_filters', $add_prefix_with_term );

$selected = $facet_feature->get_selected();
foreach ( $selected['taxonomies']['taxonomy']['terms'] as $key => $value ) {
$this->assertStringStartsWith( 'cap-', $key );
}
}

/**
* Utilitary function for the testGetSelected test.
*
Expand Down

0 comments on commit 994f09c

Please sign in to comment.