mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-02-19 07:12:53 +00:00
Tests: Restore blog switching in update_posts_count() test.
The previous iteration of the test passed when run in isolation but failed when running the whole test suite. Restoring the `switch_to_blog()` call allows the test to pass again pending a deeper investigation. Follow-up to [54760]. See #57023. git-svn-id: https://develop.svn.wordpress.org/trunk@54762 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
41fef2f8c9
commit
be4f63f00f
@ -21,10 +21,21 @@ if ( is_multisite() ) :
|
||||
* @covers ::_update_posts_count_on_delete
|
||||
*/
|
||||
public function test_update_posts_count() {
|
||||
$blog_id = self::factory()->blog->create();
|
||||
switch_to_blog( $blog_id );
|
||||
|
||||
$original_post_count = (int) get_site()->post_count;
|
||||
|
||||
$post_id = self::factory()->post->create();
|
||||
|
||||
$post_count_after_creating = get_site()->post_count;
|
||||
|
||||
wp_delete_post( $post_id );
|
||||
|
||||
$post_count_after_deleting = get_site()->post_count;
|
||||
|
||||
restore_current_blog();
|
||||
|
||||
/*
|
||||
* Check that posts count is updated when a post is created:
|
||||
* add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
|
||||
@ -32,9 +43,7 @@ if ( is_multisite() ) :
|
||||
* Check that _update_posts_count_on_transition_post_status() is called on that filter,
|
||||
* which then calls update_posts_count() to update the count.
|
||||
*/
|
||||
$this->assertSame( $original_post_count + 1, get_site()->post_count, 'Post count should be incremented by 1.' );
|
||||
|
||||
wp_delete_post( $post_id );
|
||||
$this->assertSame( $original_post_count + 1, $post_count_after_creating, 'Post count should be incremented by 1.' );
|
||||
|
||||
/*
|
||||
* Check that posts count is updated when a post is deleted:
|
||||
@ -43,7 +52,7 @@ if ( is_multisite() ) :
|
||||
* Check that _update_posts_count_on_delete() is called on that filter,
|
||||
* which then calls update_posts_count() to update the count.
|
||||
*/
|
||||
$this->assertSame( $original_post_count, get_site()->post_count, 'Post count should match the original count.' );
|
||||
$this->assertSame( $original_post_count, $post_count_after_deleting, 'Post count should match the original count.' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user