Skip to content

Commit

Permalink
Tests: Reset the current user before performing assertions in some co…
Browse files Browse the repository at this point in the history
…mment 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
  • Loading branch information
SergeyBiryukov committed Oct 15, 2023
1 parent 12dc9ca commit 0633814
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/phpunit/tests/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ public function test_update_comment_from_privileged_user_by_privileged_user() {
)
);

wp_set_current_user( 0 );

$comment = get_comment( $comment_id );
$expected_content = is_multisite()
? 'new comment '
: 'new comment <img onerror=demo src=x>';

$this->assertSame( $expected_content, $comment->comment_content );

wp_set_current_user( 0 );
}

public function test_update_comment_from_unprivileged_user_by_privileged_user() {
Expand Down Expand Up @@ -165,9 +165,10 @@ public function test_update_comment_from_unprivileged_user_by_privileged_user()
)
);

wp_set_current_user( 0 );

$comment = get_comment( $comment_id );
$this->assertSame( '<a href="http://example.localhost/something.html" rel="nofollow ugc">click</a>', $comment->comment_content, 'Comment: ' . $comment->comment_content );
wp_set_current_user( 0 );
}

/**
Expand Down

0 comments on commit 0633814

Please sign in to comment.