Skip to content
Snippets Groups Projects
Commit d8a8de52 authored by Erick Hitter's avatar Erick Hitter
Browse files

Tests: cover second parameter for `do_purge_excess`

parent 06a01ad0
Branches
Tags
1 merge request!12Introduce native Gutenberg controls
Pipeline #4716 passed with warnings
...@@ -108,4 +108,44 @@ class TestPurges extends WP_UnitTestCase { ...@@ -108,4 +108,44 @@ class TestPurges extends WP_UnitTestCase {
'Failed to assert that response includes expected count of purged revisions.' 'Failed to assert that response includes expected count of purged revisions.'
); );
} }
/**
* Test revision purging with manual override (Gutenberg).
*/
public function test_purge_excess_gutenberg() {
$post_id = $this->factory->post->create();
$iterations = 10;
$limit = 4;
for ( $i = 0; $i < $iterations; $i++ ) {
wp_update_post(
array(
'ID' => $post_id,
'post_content' => wp_rand(),
)
);
}
$revisions_to_purge = count( wp_get_post_revisions( $post_id ) );
$this->assertEquals(
$iterations,
$revisions_to_purge,
'Failed to assert that there are revisions to purge.'
);
$purge = WP_Revisions_Control::get_instance()->do_purge_excess( $post_id, $limit );
$revisions_remaining = count( wp_get_post_revisions( $post_id ) );
$this->assertEquals(
4,
$revisions_remaining,
'Failed to assert that specified number of revisions were retained.'
);
$this->assertEquals(
6,
$purge['count'],
'Failed to assert that response includes expected count of purged revisions.'
);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment