Skip to content

Commit

Permalink
Test deleting user without reassinging.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Feb 4, 2025
1 parent 4b24cfd commit 2442ed0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/phpunit/tests/user/countUserPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ public function test_reassigning_users_posts_modifies_count() {
$this->assertSame( '4', count_user_posts( $new_user_id ), 'New user is expected to have a count of four posts following reassignment.' );
}

/**
* Post count be correct after deleting user without reassigning posts.
*
* @ticket 39242
*/
public function test_post_count_retained_after_deleting_user_without_reassigning_posts() {
$this->assertSame( '4', count_user_posts( self::$user_id ), 'User is expected to have a count of four posts prior to deletion.' );

// Delete the original user without reassigning their posts.
wp_delete_user( self::$user_id );

$this->assertSame( '0', count_user_posts( self::$user_id ), 'User is expected to have a count of zero posts following deletion.' );
}

/**
* Post count should work for users that don't exist but have posts assigned.
*
Expand Down

0 comments on commit 2442ed0

Please sign in to comment.