From 0633814df899694d29e185763776000a933b92fe Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 15 Oct 2023 08:07:11 +0000 Subject: [PATCH] Tests: Reset the current user before performing assertions in some comment tests. This aims to avoid affecting other tests in case of failure. Follow-up to [54527]. See #58955. git-svn-id: https://develop.svn.wordpress.org/trunk@56936 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/comment.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index d37007d824..2af822f456 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -121,14 +121,14 @@ class Tests_Comment extends WP_UnitTestCase { ) ); + wp_set_current_user( 0 ); + $comment = get_comment( $comment_id ); $expected_content = is_multisite() ? 'new comment ' : 'new comment '; $this->assertSame( $expected_content, $comment->comment_content ); - - wp_set_current_user( 0 ); } public function test_update_comment_from_unprivileged_user_by_privileged_user() { @@ -165,9 +165,10 @@ class Tests_Comment extends WP_UnitTestCase { ) ); + wp_set_current_user( 0 ); + $comment = get_comment( $comment_id ); $this->assertSame( 'click', $comment->comment_content, 'Comment: ' . $comment->comment_content ); - wp_set_current_user( 0 ); } /**