diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test
index 2e96ba3..a49bf9b 100644
--- a/core/modules/comment/comment.test
+++ b/core/modules/comment/comment.test
@@ -331,8 +331,6 @@ class CommentInterfaceTest extends CommentHelperCase {
     $comment = $this->postComment($this->node, $comment_text);
     $comment_loaded = comment_load($comment->id);
     $this->assertTrue($this->commentExists($comment), t('Comment found.'));
-    $by_viewer_class = $this->xpath('//a[@id=:comment_id]/following-sibling::div[1][contains(@class, "comment-by-viewer")]', array(':comment_id' => 'comment-' . $comment->id));
-    $this->assertTrue(!empty($by_viewer_class), t('HTML class for comments by viewer found.'));
 
     // Set comments to have subject and preview to required.
     $this->drupalLogout();
@@ -419,11 +417,6 @@ class CommentInterfaceTest extends CommentHelperCase {
     $this->assertTrue($this->commentExists($reply, TRUE), t('Page two exists. %s'));
     $this->setCommentsPerPage(50);
 
-    // Create comment #5 to assert HTML class.
-    $comment = $this->postComment($this->node, $this->randomName(), $this->randomName());
-    $by_node_author_class = $this->xpath('//a[@id=:comment_id]/following-sibling::div[1][contains(@class, "comment-by-node-author")]', array(':comment_id' => 'comment-' . $comment->id));
-    $this->assertTrue(!empty($by_node_author_class), t('HTML class for node author found.'));
-
     // Attempt to post to node with comments disabled.
     $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_HIDDEN));
     $this->assertTrue($this->node, t('Article node created.'));
@@ -473,6 +466,95 @@ class CommentInterfaceTest extends CommentHelperCase {
   }
 
   /**
+   * Tests the comment classes.
+   */
+  function testCommentClasses() {
+    $langcode = LANGUAGE_NONE;
+    // Create all comment/user/node permutations.
+    $parameters = array(
+      'comment_uid' => array(0, $this->web_user->uid),
+      'node_uid' => array(0, $this->web_user->uid, $this->admin_user->uid),
+      'user' => array(drupal_anonymous_user(), $this->web_user, $this->admin_user),
+      'comment_status' => array(COMMENT_PUBLISHED, COMMENT_NOT_PUBLISHED),
+    );
+    $permutations = $this->generatePermutations($parameters);
+
+    foreach ($permutations as $permuta) {
+      // Create a new node.
+      $node = $this->drupalCreateNode(array('type' => 'article', 'uid' => $permuta['node_uid']));
+
+      // Add a comment.
+      $comment = (object) array(
+        'cid' => NULL,
+        'nid' => $node->nid,
+        'node_type' => $node->type,
+        'pid' => 0,
+        'uid' => $permuta['comment_uid'],
+        'status' => $permuta['comment_status'],
+        'subject' => $this->randomName(),
+        'hostname' => ip_address(),
+        'language' => LANGUAGE_NONE,
+        'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
+      );
+      comment_save($comment);
+
+      // Set the viewer user.
+      if ($permuta['user']->uid == 0) {
+        // Anonymous user.
+        $this->drupalLogout();
+      }
+      else {
+        $this->drupalLogin($permuta['user']);
+      }
+
+      // Recover the node with the comment.
+      $this->drupalGet('node/' . $node->nid);
+
+      // Check the comment-by-anonymous class.
+      if ($permuta['comment_status'] == COMMENT_PUBLISHED || $permuta['user']->uid == $this->admin_user->uid) {
+        $anonymous_class = $this->xpath('//div[contains(@class, "comment-by-anonymous")]');
+        if ($permuta['comment_uid'] == 0) {
+          $this->assertTrue(!empty($anonymous_class), 'comment-by-anonymous classt found.');
+        }
+        else {
+          $this->assertFalse($anonymous_class, 'comment-by-anonymous class not found.');
+        }
+      }
+
+      // Check the comment-by-node-author class.
+      if ($permuta['comment_status'] == COMMENT_PUBLISHED || $permuta['user']->uid == $this->admin_user->uid) {
+        $author_class = $this->xpath('//div[contains(@class, "comment-by-node-author")]');
+        if ($permuta['comment_uid'] > 0 && $permuta['comment_uid'] == $permuta['node_uid']) {
+          $this->assertTrue(!empty($author_class), 'comment-by-node-author class found.');
+        }
+        else {
+          $this->assertFalse($author_class, 'comment-by-node-author class not found.');
+        }
+      }
+
+      // Check the comment-by-viewer class.
+      if ($permuta['comment_status'] == COMMENT_PUBLISHED || $permuta['user']->uid == $this->admin_user->uid) {
+        $viewer_class = $this->xpath('//div[contains(@class, "comment-by-viewer")]');
+        if ($permuta['comment_uid'] > 0 && $permuta['comment_uid'] == $permuta['user']->uid) {
+          $this->assertTrue(!empty($viewer_class), 'comment-by-viewer class found.');
+        }
+        else {
+          $this->assertFalse($viewer_class, 'comment-by-viewer class not found.');
+        }
+      }
+
+      // Check the comment-unpublished class.
+      $unpublished_class = $this->xpath('//div[contains(@class, "comment-unpublished")]');
+      if ($permuta['comment_status'] == COMMENT_NOT_PUBLISHED && $permuta['user']->uid == $this->admin_user->uid) {
+        $this->assertTrue(!empty($unpublished_class), 'comment-unpublished class found.');
+      }
+      else {
+        $this->assertFalse($unpublished_class, 'comment-unpublished class not found.');
+      }
+    }
+  }
+
+  /**
    * Tests the node comment statistics.
    */
   function testCommentNodeCommentStatistics() {
@@ -970,8 +1052,6 @@ class CommentAnonymous extends CommentHelperCase {
     // Post anonymous comment without contact info.
     $anonymous_comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
     $this->assertTrue($this->commentExists($anonymous_comment1), t('Anonymous comment without contact info found.'));
-    $anonymous_class = $this->xpath('//a[@id=:comment_id]/following-sibling::div[1][contains(@class, "comment-by-anonymous")]', array(':comment_id' => 'comment-' . $anonymous_comment1->id));
-    $this->assertTrue(!empty($anonymous_class), t('HTML class for anonymous comments found.'));
 
     // Allow contact info.
     $this->drupalLogin($this->admin_user);
