Build/Test Tools: Add @covers tags to the comments tests.

Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@53863 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2022-08-08 23:12:30 +00:00
parent 041a9256fb
commit 57b08d1998
29 changed files with 626 additions and 3 deletions

View File

@ -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(

View File

@ -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(

View File

@ -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() {

View File

@ -2,6 +2,7 @@
/**
* @group comment
*
* @covers ::comment_form
*/
class Tests_Comment_CommentForm extends WP_UnitTestCase {

View File

@ -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 {

View File

@ -12,6 +12,8 @@
* @group comment
* @group date
* @group datequery
*
* @covers ::get_comments
*/
class Tests_Comment_DateQuery extends WP_UnitTestCase {

View File

@ -1,6 +1,8 @@
<?php
/**
* @group comment
*
* @covers ::get_comment_author_email_link
*/
class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
public static $comment;

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
*@covers ::get_comment_author_url
*/
class Tests_Comment_GetCommentAuthorUrl extends WP_UnitTestCase {
public function get_comment_author_url_filter( $url, $id, $comment ) {

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers ::get_comment_author_url_link
*/
class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
protected static $comments = array();

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers ::get_comment_class
*/
class Tests_Comment_GetCommentClass extends WP_UnitTestCase {
public function test_should_accept_comment_id() {

View File

@ -1,5 +1,12 @@
<?php
/**
* @group comment
*
* Class Tests_Get_Comment_Count
*
* @covers ::get_comment_count
*/
class Tests_Get_Comment_Count extends WP_UnitTestCase {
public function test_get_comment_count() {

View File

@ -1,5 +1,12 @@
<?php
/**
* @group comment
*
* Class Tests_Get_Comment_Excerpt
*
* @covers ::get_comment_excerpt
*/
class Tests_Get_Comment_Excerpt extends WP_UnitTestCase {
protected static $bacon_comment = 'Bacon ipsum dolor amet porchetta capicola sirloin prosciutto brisket shankle jerky. Ham hock filet mignon boudin ground round, prosciutto alcatra spare ribs meatball turducken pork beef ribs ham beef. Bacon pastrami short loin, venison tri-tip ham short ribs doner swine. Tenderloin pig tongue pork jowl doner. Pork loin rump t-bone, beef strip steak flank drumstick tri-tip short loin capicola jowl. Cow filet mignon hamburger doner rump. Short loin jowl drumstick, tongue tail beef ribs pancetta flank brisket landjaeger chuck venison frankfurter turkey.

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers ::get_comment_link
*/
class Tests_Comment_GetCommentLink extends WP_UnitTestCase {
protected static $p;

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers ::get_comment_reply_link
*/
class Tests_Comment_GetCommentReplyLink extends WP_UnitTestCase {
/**

View File

@ -3,6 +3,8 @@
* Validate the logic of get_comments_pages_count
*
* @group comment
*
* @covers ::get_comment_pages_count
*/
class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
protected $option_page_comments;

View File

@ -2,6 +2,7 @@
/**
* @group comment
*
* @covers ::get_page_of_comment
*/
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {

View File

@ -11,9 +11,10 @@
* Tests_Comment_IsAvatarCommentType class.
*
* @group comment
* @covers ::is_avatar_comment_type
*
* @since 5.1.0
*
* @covers ::is_avatar_comment_type
*/
class Tests_Comment_IsAvatarCommentType extends WP_UnitTestCase {
/**

View File

@ -3,6 +3,8 @@
/**
* @group comment
* @ticket 38027
*
* @covers ::get_lastcommentmodified
*/
class Tests_Comment_Last_Modified extends WP_UnitTestCase {
public function test_no_comments() {

View File

@ -1,11 +1,15 @@
<?php
/**
* @group comment
*/
class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
protected $i = 0;
protected $queries = 0;
/**
* @ticket 16894
*
* @covers ::update_comment_meta
*/
public function test_update_comment_meta_cache_should_default_to_true() {
global $wpdb;
@ -36,6 +40,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
/**
* @ticket 16894
*
* @covers ::update_comment_meta
*/
public function test_update_comment_meta_cache_true() {
global $wpdb;
@ -67,6 +73,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
/**
* @ticket 16894
*
* @covers ::update_comment_meta
*/
public function test_update_comment_meta_cache_false() {
global $wpdb;
@ -95,6 +103,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
/**
* @ticket 16894
*
* @covers ::get_comment_meta
*/
public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template() {
global $wpdb;
@ -130,6 +140,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
/**
* @ticket 34047
*
* @covers ::get_comment_meta
*/
public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries() {
global $wpdb;
@ -178,6 +190,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
/**
* @ticket 34047
*
* @covers ::get_comment_meta
*/
public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_feed_queries() {
global $wpdb;
@ -227,6 +241,8 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
/**
* @ticket 44467
*
* @covers ::add_metadata
*/
public function test_add_metadata_sets_comments_last_changed() {
$comment_id = self::factory()->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();

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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;

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers ::wp_list_comments
*/
class Tests_Comment_Walker extends WP_UnitTestCase {

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers ::wp_allow_comment
*/
class Tests_Comment_WpAllowComment extends WP_UnitTestCase {
protected static $post_id;

View File

@ -2,6 +2,7 @@
/**
* @group comment
*
* @covers ::_wp_batch_update_comment_type
*/
class Tests_Batch_Update_Comment_Type extends WP_UnitTestCase {

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers WP_Comment::get_instance
*/
class Tests_Term_WpComment extends WP_UnitTestCase {
protected static $comment_id;

View File

@ -1,5 +1,12 @@
<?php
/**
* @group comment
*
* Class Tests_WP_Count_Comments
*
* @covers ::wp_count_comments
*/
class Tests_WP_Count_Comments extends WP_UnitTestCase {
public function test_wp_count_comments() {

View File

@ -2,6 +2,8 @@
/**
* @group comment
*
* @covers ::wp_list_comments
*/
class Tests_Comment_WpListComments extends WP_UnitTestCase {
/**

View File

@ -2,6 +2,7 @@
/**
* @group comment
*
* @covers ::wp_update_comment_count_now
*/
class Tests_Update_Comment_Count_Now extends WP_UnitTestCase {