From cc4767cec0f2048b666901f806a03959183e852b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 30 Jun 2020 12:27:05 +0000 Subject: [PATCH] Tests: Place `remove_filter()` calls for `_wp_update_comment_data_filter()` before the assertions, for consistency with other tests. Follow-up to [48154], [48222]. See #39732. git-svn-id: https://develop.svn.wordpress.org/trunk@48231 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/comment.php | 5 ++++- tests/phpunit/tests/rest-api/rest-comments-controller.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index 8acbe29e2b..5d4fa6e4f0 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -149,6 +149,7 @@ class Tests_Comment extends WP_UnitTestCase { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); add_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); + $result = wp_update_comment( array( 'comment_ID' => $comment_id, @@ -156,8 +157,10 @@ class Tests_Comment extends WP_UnitTestCase { ), true ); - $this->assertWPError( $result ); + remove_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); + + $this->assertWPError( $result ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 5bf7cd10dc..84b2d51dd3 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -2808,9 +2808,9 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertErrorResponse( 'rest_comment_failed_edit', $response, 500 ); - remove_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); + + $this->assertErrorResponse( 'rest_comment_failed_edit', $response, 500 ); } /**