Skip to content

Commit

Permalink
Merge pull request #3184 from 10up/chore-3054/add-tests-for-3106
Browse files Browse the repository at this point in the history
Add unit test for #3106
  • Loading branch information
felipeelia authored Dec 8, 2022
2 parents 40d6738 + ad92e0d commit c7040ca
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/php/TestAdminNotices.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ function() {
}
);
ElasticPress\Screen::factory()->set_current_screen( 'install' );

add_filter(
'ep_post_pre_meta_keys_db',
function() {
Expand Down Expand Up @@ -616,6 +616,33 @@ function( $values ) {
$this->assertSame( 'error', $notices['too_many_fields']['type'] );
}

/**
* Tests notice is show when number of posts linked with term is greater than number of items per cycle.
*
*/
public function testNumberOfPostsBiggerThanItemPerCycle() {

global $pagenow, $tax;

// set global variables.
$pagenow = 'edit-tags.php';
$tax = get_taxonomy( 'category' );

$number_of_posts = ElasticPress\IndexHelper::factory()->get_index_default_per_page() + 10;
$term = $this->factory->term->create_and_get( array( 'taxonomy' => 'category' ) );
$this->posts = $this->factory->post->create_many( $number_of_posts, [
'tax_input' => [
'category' => [
$term->term_id,
],
],
] );

$notices = ElasticPress\AdminNotices::factory()->get_notices();

$this->assertArrayHasKey( 'too_many_posts_on_term', $notices );
}

/**
* Utilitary function to set `ep_post_mapping_version_determined`
* as the wanted Mapping version.
Expand Down

0 comments on commit c7040ca

Please sign in to comment.