diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 05e6e24f6b0c6..83cf6a505519d 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -855,17 +855,18 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
-
comment->create_and_get( + array( + 'comment_post_ID' => self::factory()->post->create(), + 'comment_type' => $comment_type, + ) + ); + + $output = get_echo( '_wp_dashboard_recent_comments_row', array( &$comment ) ); + + $this->assertStringContainsString( '
assertMatchesRegularExpression( '/class="dashboard-comment-wrap[^"]*\shas-avatar"/', $output );
+ }
+
+ /**
+ * @ticket 66889
+ *
+ * @dataProvider data_comment_types
+ *
+ * @param string $comment_type Comment type.
+ */
+ public function test_row_wrapper_has_no_avatar_class_when_avatars_are_disabled( $comment_type ) {
+ update_option( 'show_avatars', 0 );
+
+ $comment = self::factory()->comment->create_and_get(
+ array(
+ 'comment_post_ID' => self::factory()->post->create(),
+ 'comment_type' => $comment_type,
+ )
+ );
+
+ $output = get_echo( '_wp_dashboard_recent_comments_row', array( &$comment ) );
+
+ $this->assertStringNotContainsString( 'has-avatar', $output );
+ }
+
+ /**
+ * @ticket 66889
+ */
+ public function test_row_wrapper_has_no_avatar_class_when_avatar_is_not_rendered() {
+ $comment = self::factory()->comment->create_and_get(
+ array(
+ 'comment_post_ID' => self::factory()->post->create(),
+ 'comment_type' => 'pingback',
+ )
+ );
+
+ $output = get_echo( '_wp_dashboard_recent_comments_row', array( &$comment ) );
+
+ $this->assertStringNotContainsString( 'has-avatar', $output, 'Pingbacks do not get avatars by default.' );
+ }
+
+ /**
+ * Data provider.
+ *
+ * @return array[]
+ */
+ public function data_comment_types() {
+ return array(
+ 'regular comment' => array( 'comment' ),
+ 'custom type' => array( 'example_review' ),
+ );
+ }
+}