diff --git a/tests/phpunit/tests/comment-submission.php b/tests/phpunit/tests/comment-submission.php index 6864c776b0..14275494db 100644 --- a/tests/phpunit/tests/comment-submission.php +++ b/tests/phpunit/tests/comment-submission.php @@ -39,6 +39,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { require_once ABSPATH . WPINC . '/class-phpass.php'; } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_invalid_post_returns_error() { $error = 'comment_id_not_found'; @@ -55,6 +58,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_post_with_closed_comments_returns_error() { $error = 'comment_closed'; @@ -78,6 +84,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_trashed_post_returns_error() { $error = 'comment_on_trash'; @@ -99,6 +108,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_draft_post_returns_error() { $error = 'comment_on_draft'; @@ -124,6 +136,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 39650 + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_comment_to_draft_post_returns_error_message_for_user_with_correct_caps() { $error = 'comment_on_draft'; @@ -150,6 +164,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { $this->assertNotEmpty( $comment->get_error_message() ); } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_scheduled_post_returns_error() { // Same error as commenting on a draft. @@ -176,6 +193,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_password_required_post_returns_error() { $error = 'comment_on_password_protected'; @@ -199,6 +219,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_password_protected_post_succeeds() { if ( PHP_VERSION_ID >= 80100 ) { /* @@ -236,6 +259,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_valid_comment_as_logged_in_user_succeeds() { $user = self::factory()->user->create_and_get( @@ -263,6 +289,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_valid_comment_anonymously_succeeds() { $data = array( @@ -289,6 +318,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { * wp_handle_comment_submission() expects un-slashed data. * * @group slashes + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_comment_handles_slashes_correctly_handles_slashes() { if ( PHP_VERSION_ID >= 80100 ) { @@ -318,6 +349,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_anonymously_to_private_post_returns_error() { $error = 'comment_id_not_found'; @@ -339,6 +373,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_as_logged_in_user_to_inaccessible_private_post_returns_error() { $error = 'comment_id_not_found'; @@ -369,6 +406,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_private_post_with_closed_comments_returns_correct_error() { $error = 'comment_id_not_found'; @@ -400,6 +440,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_own_private_post_succeeds() { wp_set_current_user( self::$author_id ); @@ -423,6 +466,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_to_accessible_private_post_succeeds() { wp_set_current_user( self::$editor_id ); @@ -446,6 +492,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_anonymous_user_cannot_comment_unfiltered_html() { if ( PHP_VERSION_ID >= 80100 ) { /* @@ -471,6 +520,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_unprivileged_user_cannot_comment_unfiltered_html() { wp_set_current_user( self::$author_id ); @@ -489,6 +541,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() { wp_set_current_user( self::$author_id ); @@ -513,6 +568,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_privileged_user_can_comment_unfiltered_html_with_valid_nonce() { $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) ); @@ -545,6 +603,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() { if ( is_multisite() ) { @@ -569,6 +630,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_as_anonymous_user_when_registration_required_returns_error() { $error = 'not_logged_in'; @@ -588,6 +652,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_with_no_name_when_name_email_required_returns_error() { $error = 'require_name_email'; @@ -609,6 +676,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_with_no_email_when_name_email_required_returns_error() { $error = 'require_name_email'; @@ -630,6 +700,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_with_invalid_email_when_name_email_required_returns_error() { $error = 'require_valid_email'; @@ -652,6 +725,9 @@ class Tests_Comment_Submission extends WP_UnitTestCase { } + /** + * @covers ::wp_handle_comment_submission + */ public function test_submitting_comment_with_no_comment_content_returns_error() { $error = 'require_valid_comment'; @@ -671,6 +747,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 10377 + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_comment_with_content_too_long_returns_error() { $error = 'comment_content_column_length'; @@ -689,6 +767,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 10377 + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_comment_with_author_too_long_returns_error() { $error = 'comment_author_column_length'; @@ -707,6 +787,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 10377 + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_comment_with_email_too_long_returns_error() { $error = 'comment_author_email_column_length'; @@ -725,6 +807,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 10377 + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_comment_with_url_too_long_returns_error() { $error = 'comment_author_url_column_length'; @@ -744,6 +828,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 49236 + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_comment_with_empty_type_results_in_correct_type() { if ( PHP_VERSION_ID >= 80100 ) { @@ -773,6 +859,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 49236 + * + * @covers ::wp_insert_comment */ public function test_inserting_comment_with_empty_type_results_in_correct_type() { $data = array( @@ -793,6 +881,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 34997 + * + * @covers ::wp_handle_comment_submission */ public function test_comment_submission_sends_all_expected_parameters_to_preprocess_comment_filter() { @@ -837,6 +927,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 36901 + * + * @covers ::wp_handle_comment_submission */ public function test_submitting_duplicate_comments() { if ( PHP_VERSION_ID >= 80100 ) { @@ -863,6 +955,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 36901 + * + * @covers ::wp_handle_comment_submission */ public function test_comments_flood() { if ( PHP_VERSION_ID >= 80100 ) { @@ -892,6 +986,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase { /** * @ticket 36901 + * + * @covers ::wp_handle_comment_submission */ public function test_comments_flood_user_is_admin() { $user = self::factory()->user->create_and_get( diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index db21e79f10..a847784d87 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -30,6 +30,9 @@ class Tests_Comment extends WP_UnitTestCase { ); } + /** + * @covers ::wp_update_comment + */ public function test_wp_update_comment() { $post = self::factory()->post->create_and_get( array( @@ -78,6 +81,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 30627 + * + * @covers ::wp_update_comment */ public function test_wp_update_comment_updates_comment_type() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -95,6 +100,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 36784 + * + * @covers ::wp_update_comment */ public function test_wp_update_comment_updates_comment_meta() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -114,6 +121,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 30307 + * + * @covers ::wp_update_comment */ public function test_wp_update_comment_updates_user_id() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -131,6 +140,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 34954 + * + * @covers ::wp_update_comment */ public function test_wp_update_comment_with_no_post_id() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => 0 ) ); @@ -152,6 +163,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 39732 + * + * @covers ::wp_update_comment */ public function test_wp_update_comment_returns_false_for_invalid_comment_or_post_id() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -175,6 +188,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 39732 + * + * @covers ::wp_update_comment */ public function test_wp_update_comment_is_wp_error() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -201,6 +216,9 @@ class Tests_Comment extends WP_UnitTestCase { return new WP_Error( 'comment_wrong', 'wp_update_comment_data filter fails for this comment.', 500 ); } + /** + * @covers ::get_approved_comments + */ public function test_get_approved_comments() { $ca1 = self::factory()->comment->create( array( @@ -257,6 +275,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 30412 + * + * @covers ::get_approved_comments */ public function test_get_approved_comments_with_post_id_0_should_return_empty_array() { $ca1 = self::factory()->comment->create( @@ -273,6 +293,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 14279 + * + * @covers ::wp_new_comment */ public function test_wp_new_comment_respects_dates() { $data = array( @@ -296,6 +318,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 14601 + * + * @covers ::wp_new_comment */ public function test_wp_new_comment_respects_author_ip() { $data = array( @@ -317,6 +341,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 14601 + * + * @covers ::wp_new_comment */ public function test_wp_new_comment_respects_author_ip_empty_string() { $data = array( @@ -338,6 +364,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 14601 + * + * @covers ::wp_new_comment */ public function test_wp_new_comment_respects_comment_agent() { $data = array( @@ -360,6 +388,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 14601 + * + * @covers ::wp_new_comment */ public function test_wp_new_comment_should_trim_provided_comment_agent_to_254_chars() { $data = array( @@ -382,6 +412,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 14601 + * + * @covers ::wp_new_comment */ public function test_wp_new_comment_respects_comment_agent_empty_string() { $data = array( @@ -402,7 +434,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertSame( $data['comment_agent'], $comment->comment_agent ); } - + /** + * @covers ::wp_new_comment + */ public function test_comment_field_lengths() { $data = array( 'comment_post_ID' => self::$post_id, @@ -424,6 +458,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 32566 + * + * @covers ::wp_notify_moderator */ public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() { $p = self::factory()->post->create( @@ -441,6 +477,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( wp_notify_moderator( $c ) ); } + /** + * @covers ::wp_new_comment_notify_postauthor + */ public function test_wp_new_comment_notify_postauthor_should_send_email_when_comment_is_approved() { $c = self::factory()->comment->create( array( @@ -452,6 +491,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( $sent ); } + /** + * @covers ::wp_new_comment_notify_postauthor + */ public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_is_unapproved() { $c = self::factory()->comment->create( array( @@ -466,6 +508,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 33587 + * + * @covers ::wp_new_comment_notify_postauthor */ public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() { $c = self::factory()->comment->create( @@ -481,6 +525,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 35006 + * + * @covers ::wp_new_comment_notify_postauthor */ public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_trashed() { $c = self::factory()->comment->create( @@ -496,6 +542,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 43805 + * + * @covers ::wp_new_comment_notify_postauthor */ public function test_wp_new_comment_notify_postauthor_content_should_include_link_to_parent() { $c1 = self::factory()->comment->create( @@ -520,6 +568,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 43805 + * + * @covers ::wp_new_comment_notify_moderator */ public function test_wp_new_comment_notify_moderator_content_should_include_link_to_parent() { $c1 = self::factory()->comment->create( @@ -556,6 +606,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 12431 + * + * @covers ::get_comment_meta */ public function test_wp_new_comment_with_meta() { $c = self::factory()->comment->create( @@ -573,6 +625,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment::get_children */ public function test_wp_comment_get_children_should_fill_children() { $c1 = self::factory()->comment->create( @@ -633,6 +687,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 27571 + * + * @covers ::get_comment */ public function test_post_properties_should_be_lazyloaded() { $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -684,6 +740,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 761 + * + * @covers ::wp_new_comment */ public function test_wp_notify_moderator_filter_moderation_notify_option_true_filter_false() { $comment_data = $this->setup_notify_comment(); @@ -705,6 +763,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 761 + * + * @covers ::wp_new_comment */ public function test_wp_notify_moderator_filter_moderation_notify_option_false_filter_true() { $comment_data = $this->setup_notify_comment(); @@ -726,6 +786,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 761 + * + * @covers ::wp_new_comment */ public function test_wp_notify_post_author_filter_comments_notify_option_true_filter_false() { @@ -748,6 +810,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 761 + * + * @covers ::wp_new_comment */ public function test_wp_notify_post_author_filter_comments_notify_option_false_filter_true() { $comment_data = $this->setup_notify_comment(); @@ -852,6 +916,9 @@ class Tests_Comment extends WP_UnitTestCase { return $email_sent_when_comment_approved || $email_sent_when_comment_added; } + /** + * @covers ::_close_comments_for_old_post + */ public function test_close_comments_for_old_post() { update_option( 'close_comments_for_old_posts', true ); // Close comments more than one day old. @@ -867,6 +934,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( $new_post_comment_status ); } + /** + * @covers ::_close_comments_for_old_post + */ public function test_close_comments_for_old_post_undated_draft() { $draft_id = self::factory()->post->create( array( @@ -881,6 +951,8 @@ class Tests_Comment extends WP_UnitTestCase { /** * @ticket 35276 + * + * @covers ::wp_update_comment */ public function test_wp_update_comment_author_id_and_agent() { @@ -917,6 +989,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertSame( 'SHIELD_AGENT', $updated->comment_agent ); } + /** + * @covers ::wp_get_comment_fields_max_lengths + */ public function test_wp_get_comment_fields_max_lengths() { $expected = array( 'comment_author' => 245, @@ -937,6 +1012,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43442 + * + * @covers ::wp_comments_personal_data_eraser */ public function test_wp_comments_personal_data_eraser() { @@ -994,6 +1071,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43442 + * + * @covers ::wp_comments_personal_data_eraser */ public function test_wp_comments_personal_data_eraser_empty_first_page_output() { @@ -1013,6 +1092,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43442 + * + * @covers ::wp_comments_personal_data_eraser */ public function test_wp_comments_personal_data_eraser_non_empty_first_page_output() { @@ -1045,6 +1126,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43442 + * + * @covers ::wp_comments_personal_data_eraser */ public function test_wp_comments_personal_data_eraser_empty_second_page_output() { @@ -1077,6 +1160,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43442 + * + * @covers ::wp_comments_personal_data_eraser */ public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization() { @@ -1114,6 +1199,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43442 + * + * @covers ::wp_comments_personal_data_eraser */ public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization_with_custom_message() { @@ -1179,6 +1266,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertSame( 'Bar', $comment->comment_author ); } + /** + * @covers ::wp_trash_comment + */ public function test_trash_should_invalidate_comment_cache() { global $wpdb; @@ -1193,6 +1283,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertSame( 'trash', $comment->comment_approved ); } + /** + * @covers ::wp_untrash_comment + */ public function test_untrash_should_invalidate_comment_cache() { global $wpdb; @@ -1209,6 +1302,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertSame( '1', $comment->comment_approved ); } + /** + * @covers ::wp_spam_comment + */ public function test_spam_should_invalidate_comment_cache() { global $wpdb; @@ -1223,6 +1319,9 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertSame( 'spam', $comment->comment_approved ); } + /** + * @covers ::wp_unspam_comment + */ public function test_unspam_should_invalidate_comment_cache() { global $wpdb; @@ -1244,6 +1343,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43440 + * + * @covers ::wp_comments_personal_data_exporter */ public function test_wp_comments_personal_data_exporter() { $args = array( @@ -1290,6 +1391,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43440 + * + * @covers ::wp_comments_personal_data_exporter */ public function test_wp_comments_personal_data_exporter_no_comments_found() { @@ -1308,6 +1411,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43440 + * + * @covers ::wp_comments_personal_data_exporter */ public function test_wp_comments_personal_data_exporter_empty_comment_prop() { $args = array( @@ -1339,6 +1444,8 @@ class Tests_Comment extends WP_UnitTestCase { * * @group privacy * @ticket 43440 + * + * @covers ::wp_comments_personal_data_exporter */ public function test_wp_comments_personal_data_exporter_empty_second_page() { $args = array( diff --git a/tests/phpunit/tests/comment/checkComment.php b/tests/phpunit/tests/comment/checkComment.php index fc4cfa9e83..c6ac824a24 100644 --- a/tests/phpunit/tests/comment/checkComment.php +++ b/tests/phpunit/tests/comment/checkComment.php @@ -2,6 +2,8 @@ /** * @group comment + * + * @covers ::check_comment */ class Tests_Comment_CheckComment extends WP_UnitTestCase { public function test_should_return_true_when_comment_previously_approved_is_disabled() { diff --git a/tests/phpunit/tests/comment/commentForm.php b/tests/phpunit/tests/comment/commentForm.php index eef2e9ac7c..e9e6d99e73 100644 --- a/tests/phpunit/tests/comment/commentForm.php +++ b/tests/phpunit/tests/comment/commentForm.php @@ -2,6 +2,7 @@ /** * @group comment + * * @covers ::comment_form */ class Tests_Comment_CommentForm extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/comment/commentsTemplate.php b/tests/phpunit/tests/comment/commentsTemplate.php index 7135118485..7c27bf1d43 100644 --- a/tests/phpunit/tests/comment/commentsTemplate.php +++ b/tests/phpunit/tests/comment/commentsTemplate.php @@ -4,6 +4,8 @@ * @group comment * * Testing items that are only testable by grabbing the markup of `comments_template()` from the output buffer. + * + * @covers ::comments_template */ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/comment/dateQuery.php b/tests/phpunit/tests/comment/dateQuery.php index c59497a835..473c2a6c26 100644 --- a/tests/phpunit/tests/comment/dateQuery.php +++ b/tests/phpunit/tests/comment/dateQuery.php @@ -12,6 +12,8 @@ * @group comment * @group date * @group datequery + * + * @covers ::get_comments */ class Tests_Comment_DateQuery extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php b/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php index a5ed6aef6b..a203d38122 100644 --- a/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php +++ b/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php @@ -1,6 +1,8 @@ comment->create(); @@ -239,6 +255,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { /** * @ticket 44467 + * + * @covers ::update_metadata */ public function test_update_metadata_sets_comments_last_changed() { $comment_id = self::factory()->comment->create(); @@ -251,6 +269,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { /** * @ticket 44467 + * + * @covers ::delete_metadata */ public function test_delete_metadata_sets_comments_last_changed() { $comment_id = self::factory()->comment->create(); diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 2fad8fe8a2..9691235240 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -13,6 +13,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { self::$post_id = $factory->post->create(); } + /** + * @covers WP_Comment_Query::query + */ public function test_query() { $c1 = self::factory()->comment->create( array( @@ -59,6 +62,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array( $c1, $c2, $c3, $c4, $c5 ), $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_query_post_id_0() { $c1 = self::factory()->comment->create( array( @@ -80,6 +86,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_query_type_empty_string() { $c1 = self::factory()->comment->create( @@ -130,6 +138,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_query_type_comment() { $c1 = self::factory()->comment->create( @@ -178,6 +188,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array( $c1 ), $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_query_type_pingback() { $c1 = self::factory()->comment->create( array( @@ -219,6 +232,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { } + /** + * @covers WP_Comment_Query::query + */ public function test_query_type_trackback() { $c1 = self::factory()->comment->create( array( @@ -262,6 +278,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * 'pings' is an alias for 'trackback' + 'pingback'. + * + * @covers WP_Comment_Query::query */ public function test_query_type_pings() { $c1 = self::factory()->comment->create( @@ -314,6 +332,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { * Comments and custom * * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_comments_and_custom() { $c1 = self::factory()->comment->create( @@ -371,6 +391,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_not__in_array_custom() { $c1 = self::factory()->comment->create( @@ -428,6 +450,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type__in_array_and_not_type_array_custom() { $c1 = self::factory()->comment->create( @@ -486,6 +510,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_and_type__not_in_array_custom() { $c1 = self::factory()->comment->create( @@ -544,6 +570,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type__not_in_custom() { $c1 = self::factory()->comment->create( @@ -601,6 +629,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_comments_and_pings() { $c1 = self::factory()->comment->create( @@ -651,6 +681,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_comment_pings() { $c1 = self::factory()->comment->create( @@ -687,6 +719,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_pingback() { $c1 = self::factory()->comment->create( @@ -723,6 +757,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_custom_pingpack() { $c1 = self::factory()->comment->create( @@ -759,6 +795,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_pings() { $c1 = self::factory()->comment->create( @@ -795,6 +833,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_status_approved_array_comment_pings() { $c1 = self::factory()->comment->create( @@ -839,6 +879,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_trackback() { $c1 = self::factory()->comment->create( @@ -875,6 +917,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_custom_trackback() { $c1 = self::factory()->comment->create( @@ -911,6 +955,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 12668 + * + * @covers WP_Comment_Query::query */ public function test_type_array_pings_approved() { $c1 = self::factory()->comment->create( @@ -955,6 +1001,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29612 + * + * @covers WP_Comment_Query::query */ public function test_status_empty_string() { $c1 = self::factory()->comment->create( @@ -989,6 +1037,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 21101 + * + * @covers WP_Comment_Query::query */ public function test_status_hold() { $c1 = self::factory()->comment->create( @@ -1017,6 +1067,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 21101 + * + * @covers WP_Comment_Query::query */ public function test_status_approve() { $c1 = self::factory()->comment->create( @@ -1043,6 +1095,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSame( array( $c1 ), $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_status_custom() { $c1 = self::factory()->comment->create( array( @@ -1074,6 +1129,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSame( array( $c2 ), $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_status_all() { $c1 = self::factory()->comment->create( array( @@ -1105,6 +1163,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array( $c1, $c3 ), $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_status_default_to_all() { $c1 = self::factory()->comment->create( array( @@ -1137,6 +1198,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29612 + * + * @covers WP_Comment_Query::query */ public function test_status_comma_any() { $c1 = self::factory()->comment->create( @@ -1171,6 +1234,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29612 + * + * @covers WP_Comment_Query::query */ public function test_status_comma_separated() { $c1 = self::factory()->comment->create( @@ -1205,6 +1270,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29612 + * + * @covers WP_Comment_Query::query */ public function test_status_array() { $c1 = self::factory()->comment->create( @@ -1239,6 +1306,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35478 + * + * @covers WP_Comment_Query::__construct */ public function test_multiple_post_fields_should_all_be_respected() { $posts = array(); @@ -1284,6 +1353,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSame( array( $comments[2] ), $q->comments ); } + /** + * @covers ::get_comments + */ public function test_get_comments_for_post() { $limit = 5; @@ -1343,6 +1415,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 21003 + * + * @covers ::get_comments */ public function test_orderby_meta() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -1435,6 +1509,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_clause_key() { $comments = self::factory()->comment->create_many( 3 ); @@ -1462,6 +1538,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_clause_key_as_secondary_sort() { $c1 = self::factory()->comment->create( @@ -1506,6 +1584,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_more_than_one_clause_key() { $comments = self::factory()->comment->create_many( 3 ); @@ -1543,6 +1623,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 32081 + * + * @covers WP_Comment_Query::__construct + * @covers WP_Comment_Query::get_comments */ public function test_meta_query_should_work_with_comment__in() { $comments = self::factory()->comment->create_many( 3 ); @@ -1569,6 +1652,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 32081 + * + * @covers WP_Comment_Query::__construct + * @covers WP_Comment_Query::get_comments */ public function test_meta_query_should_work_with_comment__not_in() { $comments = self::factory()->comment->create_many( 3 ); @@ -1595,6 +1681,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 27064 + * + * @covers ::get_comments */ public function test_get_comments_by_user() { $users = self::factory()->user->create_many( 2 ); @@ -1649,6 +1737,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35377 + * + * @covers ::get_comments */ public function test_get_comments_by_author_url() { $c1 = self::factory()->comment->create( @@ -1688,6 +1778,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 28434 + * + * @covers ::get_comments */ public function test_fields_ids_query() { $comment_1 = self::factory()->comment->create( @@ -1724,6 +1816,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 + * + * @covers ::get_comments */ public function test_fields_comment__in() { $comment_1 = self::factory()->comment->create( @@ -1760,6 +1854,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 + * + * @covers ::get_comments */ public function test_fields_comment__not_in() { $comment_1 = self::factory()->comment->create( @@ -1796,6 +1892,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 + * + * @covers ::get_comments */ public function test_fields_post__in() { $p1 = self::factory()->post->create(); @@ -1836,6 +1934,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 + * + * @covers ::get_comments */ public function test_fields_post__not_in() { $p1 = self::factory()->post->create(); @@ -1876,6 +1976,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 + * + * @covers ::get_comments */ public function test_fields_post_author__in() { $author_id1 = 105; @@ -1919,6 +2021,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 + * + * @covers ::get_comments */ public function test_fields_post_author__not_in() { $author_id1 = 111; @@ -1962,6 +2066,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 + * + * @covers ::get_comments */ public function test_fields_author__in() { $p1 = self::factory()->post->create(); @@ -2010,6 +2116,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 + * + * @covers ::get_comments */ public function test_fields_author__not_in() { $p1 = self::factory()->post->create(); @@ -2058,6 +2166,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 19623 + * + * @covers ::get_comments */ public function test_get_comments_with_status_all() { $comment_1 = self::factory()->comment->create( @@ -2089,6 +2199,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 19623 + * + * @covers ::get_comments */ public function test_get_comments_with_include_unapproved_user_id() { $c1 = self::factory()->comment->create( @@ -2133,6 +2245,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 19623 + * + * @covers ::get_comments */ public function test_get_comments_with_include_unapproved_user_id_array() { $c1 = self::factory()->comment->create( @@ -2184,6 +2298,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 19623 + * + * @covers ::get_comments */ public function test_get_comments_with_include_unapproved_user_id_comma_separated() { $c1 = self::factory()->comment->create( @@ -2235,6 +2351,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 19623 + * + * @covers ::get_comments */ public function test_get_comments_with_include_unapproved_author_email() { $c1 = self::factory()->comment->create( @@ -2285,6 +2403,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 19623 + * + * @covers ::get_comments */ public function test_get_comments_with_include_unapproved_mixed_array() { $c1 = self::factory()->comment->create( @@ -2344,6 +2464,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 19623 + * + * @covers ::get_comments */ public function test_get_comments_with_include_unapproved_mixed_comma_separated() { $c1 = self::factory()->comment->create( @@ -2401,6 +2523,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array( $c1, $c2, $c3, $c5 ), $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_search() { $c1 = self::factory()->comment->create( array( @@ -2476,6 +2601,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35513 + * + * @covers WP_Comment_Query::query */ public function test_search_false_should_be_ignored() { $q = new WP_Comment_Query(); @@ -2489,6 +2616,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35513 + * + * @covers WP_Comment_Query::query */ public function test_search_null_should_be_ignored() { $q = new WP_Comment_Query(); @@ -2502,6 +2631,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35513 + * + * @covers WP_Comment_Query::query */ public function test_search_empty_string_should_be_ignored() { $q = new WP_Comment_Query(); @@ -2515,6 +2646,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35513 + * + * @covers WP_Comment_Query::query */ public function test_search_int_0_should_not_be_ignored() { global $wpdb; @@ -2529,6 +2662,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35513 + * + * @covers WP_Comment_Query::query */ public function test_search_string_0_should_not_be_ignored() { global $wpdb; @@ -2541,6 +2676,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_default() { global $wpdb; @@ -2550,6 +2688,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "ORDER BY $wpdb->comments.comment_date_gmt", $q->request ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_single() { global $wpdb; @@ -2563,6 +2704,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "ORDER BY $wpdb->comments.comment_agent", $q->request ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_single_invalid() { global $wpdb; @@ -2576,6 +2720,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "ORDER BY $wpdb->comments.comment_date_gmt", $q->request ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_space_separated() { global $wpdb; @@ -2589,6 +2736,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_comma_separated() { global $wpdb; @@ -2602,6 +2752,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_flat_array() { global $wpdb; @@ -2615,6 +2768,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_array_contains_invalid_item() { global $wpdb; @@ -2628,6 +2784,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertStringContainsString( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); } + /** + * @covers WP_Comment_Query::query + */ public function test_orderby_array_contains_all_invalid_items() { global $wpdb; @@ -2643,6 +2802,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29902 + * + * @covers WP_Comment_Query::query */ public function test_orderby_none() { $q = new WP_Comment_Query(); @@ -2657,6 +2818,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29902 + * + * @covers WP_Comment_Query::query */ public function test_orderby_empty_array() { $q = new WP_Comment_Query(); @@ -2671,6 +2834,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29902 + * + * @covers WP_Comment_Query::query */ public function test_orderby_false() { $q = new WP_Comment_Query(); @@ -2685,6 +2850,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_array() { global $wpdb; @@ -2706,6 +2873,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_array_should_discard_invalid_columns() { global $wpdb; @@ -2727,6 +2896,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_array_should_convert_invalid_order_to_DESC() { global $wpdb; @@ -2748,6 +2919,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_array_should_sort_by_comment_ID_as_fallback_and_should_inherit_order_from_comment_date_gmt() { global $wpdb; @@ -2768,6 +2941,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_array_should_sort_by_comment_ID_as_fallback_and_should_inherit_order_from_comment_date() { global $wpdb; @@ -2788,6 +2963,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_array_should_sort_by_comment_ID_DESC_as_fallback_when_not_sorted_by_date() { global $wpdb; @@ -2807,6 +2984,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC() { $now = current_time( 'mysql', 1 ); @@ -2832,6 +3011,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 30478 + * + * @covers WP_Comment_Query::query */ public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC() { $now = current_time( 'mysql', 1 ); @@ -2857,6 +3038,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertEquals( $comments, wp_list_pluck( $found, 'comment_ID' ) ); } + /** + * @covers WP_Comment_Query::query + */ public function test_meta_vars_should_be_converted_to_meta_query() { $q = new WP_Comment_Query(); $q->query( @@ -2874,6 +3058,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSame( 'SIGNED', $q->meta_query->queries[0]['type'] ); } + /** + * @covers WP_Comment_Query::query + */ public function test_count() { $c1 = self::factory()->comment->create( array( @@ -2900,6 +3087,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 23369 + * + * @covers WP_Comment_Query::query */ public function test_count_with_meta_query() { $c1 = self::factory()->comment->create( @@ -2941,6 +3130,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 38268 + * + * @covers WP_Comment_Query::query */ public function test_paged() { $now = time(); @@ -2987,6 +3178,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 38268 + * + * @covers WP_Comment_Query::query */ public function test_offset_should_take_precedence_over_paged() { $now = time(); @@ -3033,6 +3226,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSame( $expected, $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_post_type_single_value() { register_post_type( 'post-type-1' ); register_post_type( 'post-type-2' ); @@ -3059,6 +3255,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 20006 + * + * @covers WP_Comment_Query::query */ public function test_post_type_singleton_array() { register_post_type( 'post-type-1' ); @@ -3086,6 +3284,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 20006 + * + * @covers WP_Comment_Query::query */ public function test_post_type_array() { register_post_type( 'post-type-1' ); @@ -3111,6 +3311,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array_merge( $c1, $c3 ), $found ); } + /** + * + * @covers WP_Comment_Query::query + */ public function test_post_name_single_value() { $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) ); $p2 = self::factory()->post->create( array( 'post_name' => 'bar' ) ); @@ -3131,6 +3335,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 20006 + * + * @covers WP_Comment_Query::query */ public function test_post_name_singleton_array() { $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) ); @@ -3152,6 +3358,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 20006 + * + * @covers WP_Comment_Query::query */ public function test_post_name_array() { $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) ); @@ -3173,6 +3381,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array_merge( $c1, $c3 ), $found ); } + /** + * @covers WP_Comment_Query::query + */ public function test_post_status_single_value() { $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) ); @@ -3193,6 +3404,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 20006 + * + * @covers WP_Comment_Query::query */ public function test_post_status_singleton_array() { $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); @@ -3214,6 +3427,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 20006 + * + * @covers WP_Comment_Query::query */ public function test_post_status_array() { $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); @@ -3237,6 +3452,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35512 + * + * @covers WP_Comment_Query::query */ public function test_post_type_any_should_override_other_post_types() { register_post_type( 'post-type-1', array( 'exclude_from_search' => false ) ); @@ -3260,6 +3477,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35512 + * + * @covers WP_Comment_Query::query */ public function test_post_type_any_as_part_of_an_array_of_post_types() { register_post_type( 'post-type-1', array( 'exclude_from_search' => false ) ); @@ -3283,6 +3502,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35512 + * + * @covers WP_Comment_Query::query */ public function test_post_status_any_should_override_other_post_statuses() { $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); @@ -3303,6 +3524,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35512 + * + * @covers WP_Comment_Query::query */ public function test_post_status_any_as_part_of_an_array_of_post_statuses() { $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); @@ -3323,6 +3546,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 24826 + * + * @covers WP_Comment_Query::__construct + * @covers WP_Comment_Query::get_comments */ public function test_comment_query_object() { $comment_id = self::factory()->comment->create(); @@ -3343,6 +3569,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 22400 + * + * @covers WP_Comment_Query::query */ public function test_comment_cache_key_should_ignore_custom_params() { global $wpdb; @@ -3374,6 +3602,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35677 + * + * @covers WP_Comment_Query::__construct */ public function test_cache_should_be_sensitive_to_parent__in() { global $wpdb; @@ -3397,6 +3627,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35677 + * + * @covers WP_Comment_Query::__construct */ public function test_cache_should_be_sensitive_to_parent__not_in() { global $wpdb; @@ -3420,6 +3652,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 32762 + * + * @covers WP_Comment_Query::__construct */ public function test_it_should_be_possible_to_modify_meta_query_using_pre_get_comments_action() { $comments = self::factory()->comment->create_many( @@ -3458,6 +3692,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 32762 + * + * @covers WP_Comment_Query::__construct */ public function test_it_should_be_possible_to_modify_meta_params_using_pre_get_comments_action() { $comments = self::factory()->comment->create_many( @@ -3490,6 +3726,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 33882 + * + * @covers WP_Comment_Query::__construct */ public function test_parent__in() { $c1 = self::factory()->comment->create( @@ -3519,6 +3757,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 33882 + * + * @covers WP_Comment_Query::__construct */ public function test_parent__in_commas() { $c1 = self::factory()->comment->create( @@ -3561,6 +3801,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 33882 + * + * @covers WP_Comment_Query::__construct */ public function test_parent__not_in() { $c1 = self::factory()->comment->create( @@ -3591,6 +3833,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 33882 + * + * @covers WP_Comment_Query::__construct */ public function test_parent__not_in_commas() { $c1 = self::factory()->comment->create( @@ -3634,6 +3878,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 33883 + * + * @covers WP_Comment_Query::__construct */ public function test_orderby_comment__in() { self::factory()->comment->create( @@ -3677,6 +3923,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment_Query::__construct */ public function test_no_found_rows_should_default_to_true() { $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); @@ -3694,6 +3942,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment_Query::__construct */ public function test_should_respect_no_found_rows_true() { $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); @@ -3712,6 +3962,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment_Query::__construct */ public function test_should_respect_no_found_rows_false() { $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); @@ -3730,6 +3982,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 37184 + * + * @covers WP_Comment_Query::__construct */ public function test_found_rows_should_be_fetched_from_the_cache() { $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); @@ -3757,6 +4011,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment_Query::__construct */ public function test_hierarchical_should_skip_child_comments_in_offset() { $top_level_0 = self::factory()->comment->create( @@ -3799,6 +4055,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment_Query::__construct */ public function test_hierarchical_should_not_include_child_comments_in_number() { $top_level_0 = self::factory()->comment->create( @@ -3839,6 +4097,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment_Query::__construct */ public function test_hierarchical_threaded() { $c1 = self::factory()->comment->create( @@ -3917,6 +4177,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 8071 + * + * @covers WP_Comment_Query::__construct */ public function test_hierarchical_threaded_approved() { $c1 = self::factory()->comment->create( @@ -3993,6 +4255,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35192 + * + * @covers WP_Comment_Query::__construct */ public function test_comment_clauses_prepend_callback_should_be_respected_when_filling_descendants() { $top_level_0 = self::factory()->comment->create( @@ -4050,6 +4314,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 35192 + * + * @covers WP_Comment_Query::__construct */ public function test_comment_clauses_append_callback_should_be_respected_when_filling_descendants() { $top_level_0 = self::factory()->comment->create( @@ -4107,6 +4373,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 36487 + * + * @covers WP_Comment_Query::__construct */ public function test_cache_should_be_hit_when_querying_descendants() { global $wpdb; @@ -4163,6 +4431,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 37696 + * + * @covers WP_Comment_Query::__construct */ public function test_hierarchy_should_be_filled_when_cache_is_incomplete() { global $wpdb; @@ -4225,6 +4495,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 37966 * @ticket 37696 + * + * @covers WP_Comment_Query::query */ public function test_fill_hierarchy_should_disregard_offset_and_number() { $c0 = self::factory()->comment->create( @@ -4292,6 +4564,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 27571 + * + * @covers WP_Comment_Query::__construct */ public function test_update_comment_post_cache_should_be_disabled_by_default() { global $wpdb; @@ -4312,6 +4586,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 27571 + * + * @covers WP_Comment_Query::__construct */ public function test_should_respect_update_comment_post_cache_true() { global $wpdb; @@ -4333,6 +4609,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 34138 + * + * @covers WP_Comment_Query::__construct */ public function test_comment_objects_should_be_filled_from_cache() { global $wpdb; @@ -4361,6 +4639,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 34138 + * + * @covers WP_Comment_Query::__construct */ public function test_comment_objects_should_be_fetched_from_database_when_suspend_cache_addition() { $suspend = wp_suspend_cache_addition(); @@ -4380,6 +4660,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertEqualSets( array( $c ), $found ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_comment_query_should_be_cached() { global $wpdb; @@ -4410,6 +4693,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSame( $num_queries, $wpdb->num_queries ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_created_comment_should_invalidate_query_cache() { global $wpdb; @@ -4440,6 +4726,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array( $c ), $q->comments ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_updated_comment_should_invalidate_query_cache() { global $wpdb; @@ -4480,6 +4769,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array( $c ), $q->comments ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_deleted_comment_should_invalidate_query_cache() { global $wpdb; @@ -4513,6 +4805,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array(), $q->comments ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_trashed_comment_should_invalidate_query_cache() { global $wpdb; @@ -4546,6 +4841,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array(), $q->comments ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_untrashed_comment_should_invalidate_query_cache() { global $wpdb; @@ -4581,6 +4879,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array( $c ), $q->comments ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_spammed_comment_should_invalidate_query_cache() { global $wpdb; @@ -4614,6 +4915,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSameSets( array(), $q->comments ); } + /** + * @covers WP_Comment_Query::__construct + */ public function test_unspammed_comment_should_invalidate_query_cache() { global $wpdb; @@ -4651,6 +4955,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 41348 + * + * @covers WP_Comment_Query::query */ public function test_count_query_should_miss_noncount_cache() { global $wpdb; @@ -4680,6 +4986,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 41348 + * + * @covers WP_Comment_Query::query */ public function test_count_query_should_hit_count_cache() { global $wpdb; @@ -4709,6 +5017,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 41348 + * + * @covers WP_Comment_Query::query */ public function test_different_values_of_fields_should_share_cached_values() { global $wpdb; @@ -4737,6 +5047,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 40669 + * + * @covers ::get_comments */ public function test_add_comment_meta_should_invalidate_query_cache() { global $wpdb; @@ -4786,6 +5098,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 40669 + * + * @covers ::get_comments */ public function test_update_comment_meta_should_invalidate_query_cache() { global $wpdb; @@ -4835,6 +5149,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 40669 + * + * @covers ::get_comments */ public function test_delete_comment_meta_should_invalidate_query_cache() { global $wpdb; @@ -4884,6 +5200,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 45800 + * + * @covers WP_Comment_Query::query */ public function test_comments_pre_query_filter_should_bypass_database_query() { global $wpdb; @@ -4915,6 +5233,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 50521 + * + * @covers WP_Comment_Query::query */ public function test_comments_pre_query_filter_should_set_comments_property() { add_filter( 'comments_pre_query', array( __CLASS__, 'filter_comments_pre_query_and_set_comments' ), 10, 2 ); @@ -4944,6 +5264,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 55460 + * + * @covers WP_Comment_Query::__construct */ public function test_comment_cache_key_should_ignore_unset_params() { $p = self::factory()->post->create(); @@ -4971,6 +5293,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 55218 + * + * @covers WP_Comment_Query::__construct */ public function test_unapproved_comment_with_meta_query_does_not_trigger_ambiguous_identifier_error() { $p = self::$post_id; diff --git a/tests/phpunit/tests/comment/slashes.php b/tests/phpunit/tests/comment/slashes.php index 9651295911..e58776d8f8 100644 --- a/tests/phpunit/tests/comment/slashes.php +++ b/tests/phpunit/tests/comment/slashes.php @@ -37,6 +37,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the extended model function that expects slashed data. + * + * @covers ::wp_new_comment */ public function test_wp_new_comment() { $post_id = self::$post_id; @@ -76,6 +78,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the controller function that expects slashed data. + * + * @covers ::edit_comment */ public function test_edit_comment() { $post_id = self::$post_id; @@ -122,6 +126,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects slashed data. + * + * @covers ::wp_insert_comment */ public function test_wp_insert_comment() { $post_id = self::$post_id; @@ -153,6 +159,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects slashed data. + * + * @covers ::wp_update_comment */ public function test_wp_update_comment() { $post_id = self::$post_id; diff --git a/tests/phpunit/tests/comment/template.php b/tests/phpunit/tests/comment/template.php index 93e88ca107..7cb089d54a 100644 --- a/tests/phpunit/tests/comment/template.php +++ b/tests/phpunit/tests/comment/template.php @@ -19,6 +19,9 @@ class Tests_Comment_Template extends WP_UnitTestCase { self::$post_id = self::factory()->post->create(); } + /** + * @covers ::get_comments_number + */ public function test_get_comments_number() { $post_id = self::$post_id; @@ -32,6 +35,9 @@ class Tests_Comment_Template extends WP_UnitTestCase { $this->assertSame( '12', get_comments_number( get_post( $post_id ) ) ); } + /** + * @covers ::get_comments_number + */ public function test_get_comments_number_without_arg() { $post_id = self::$post_id; $permalink = get_permalink( $post_id ); @@ -47,6 +53,8 @@ class Tests_Comment_Template extends WP_UnitTestCase { /** * @ticket 48772 + * + * @covers ::get_comments_number_text */ public function test_get_comments_number_text_with_post_id() { $post_id = self::$post_id; @@ -66,6 +74,8 @@ class Tests_Comment_Template extends WP_UnitTestCase { /** * @ticket 13651 + * + * @covers ::get_comments_number_text */ public function test_get_comments_number_text_declension_with_default_args() { $post_id = self::$post_id; @@ -89,6 +99,8 @@ class Tests_Comment_Template extends WP_UnitTestCase { /** * @ticket 13651 * @dataProvider data_get_comments_number_text_declension + * + * @covers ::get_comments_number_text */ public function test_get_comments_number_text_declension_with_custom_args( $number, $input, $output ) { $post_id = self::$post_id; diff --git a/tests/phpunit/tests/comment/walker.php b/tests/phpunit/tests/comment/walker.php index 1027a96d14..443ca0c1cf 100644 --- a/tests/phpunit/tests/comment/walker.php +++ b/tests/phpunit/tests/comment/walker.php @@ -2,6 +2,8 @@ /** * @group comment + * + * @covers ::wp_list_comments */ class Tests_Comment_Walker extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/comment/wpAllowComment.php b/tests/phpunit/tests/comment/wpAllowComment.php index c7c32758b6..8b3de23fc1 100644 --- a/tests/phpunit/tests/comment/wpAllowComment.php +++ b/tests/phpunit/tests/comment/wpAllowComment.php @@ -2,6 +2,8 @@ /** * @group comment + * + * @covers ::wp_allow_comment */ class Tests_Comment_WpAllowComment extends WP_UnitTestCase { protected static $post_id; diff --git a/tests/phpunit/tests/comment/wpBatchUpdateCommentType.php b/tests/phpunit/tests/comment/wpBatchUpdateCommentType.php index c900e0aaf4..85a89e4cfc 100644 --- a/tests/phpunit/tests/comment/wpBatchUpdateCommentType.php +++ b/tests/phpunit/tests/comment/wpBatchUpdateCommentType.php @@ -2,6 +2,7 @@ /** * @group comment + * * @covers ::_wp_batch_update_comment_type */ class Tests_Batch_Update_Comment_Type extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/comment/wpComment.php b/tests/phpunit/tests/comment/wpComment.php index 9e0dec75e4..d5a7119deb 100644 --- a/tests/phpunit/tests/comment/wpComment.php +++ b/tests/phpunit/tests/comment/wpComment.php @@ -2,6 +2,8 @@ /** * @group comment + * + * @covers WP_Comment::get_instance */ class Tests_Term_WpComment extends WP_UnitTestCase { protected static $comment_id; diff --git a/tests/phpunit/tests/comment/wpCountComments.php b/tests/phpunit/tests/comment/wpCountComments.php index 5586889ba2..ef3e337261 100644 --- a/tests/phpunit/tests/comment/wpCountComments.php +++ b/tests/phpunit/tests/comment/wpCountComments.php @@ -1,5 +1,12 @@