Index: comment.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v
retrieving revision 1.25
diff -u -r1.25 comment.test
--- comment.test	7 Feb 2009 20:10:40 -0000	1.25
+++ comment.test	7 Mar 2009 22:36:40 -0000
@@ -611,3 +611,73 @@
     $this->assertRaw($raw, t('Comments as part of RSS feed.'));
   }
 }
+
+/**
+ * Functional test for the comment administration page.
+ */
+class CommentAdminFunctionalTest extends CommentHelperCase {
+  function getInfo() {
+    return array(
+      'name' => t('Comment Administration'),
+      'description' => t('Test the functionality of the comment administration page.'),
+      'group' =>t('Comment'),
+    );
+  }
+  
+  function testCommentAdminOperations() {
+    // Test the comment admin page when there are no comments posted
+    $this->drupalLogin($this->admin_user);
+    $this->drupalGet('admin/content/comment');
+    $this->assertText(t('No comments available.'), t('No comments were available.'));
+    
+    // Perform operations on non-selected published comments
+    $edit = array();
+    $operations = array('unpublish', 'delete');
+    foreach ($operations as $operation) {
+      $edit['operation'] = $operation;
+      $this->drupalPost('admin/content/comment', $edit, t('Update'));
+      $this->assertText(t('Please select one or more comments to perform the update on.'), t('No comments were selected to ' . $operation));
+    }
+    
+    // Perform operations on non-selected comments in the approval queue.
+    $operations = array('publish', 'delete');
+    foreach ($operations as $operation) {
+      $edit['operation'] = $operation;
+      $this->drupalPost('admin/content/comment/approval', $edit, t('Update'));
+      $this->assertText(t('Please select one or more comments to perform the update on.'), t('No comments were selected to ' . $operation));
+    }
+    
+    // Perform operations on non-existing comments
+    $comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
+    $this->drupalGet('admin/content/comment');
+    $edit = array();
+    $edit['operation'] = 'delete';
+    $edit['comments[' . $comment1->id . ']'] = TRUE;
+    // First we delete the comment from the database
+    db_query("DELETE FROM {comment} WHERE cid = %d", $comment1->id);
+    // Then we delete the comment again through the UI.
+    $this->drupalPost(NULL, $edit, t('Update'));
+    $this->assertText(t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.'), t('Comment was not found and could not be deleted.'));
+    
+    // Next test situation would not work because Drupal doesn't display a pager on the comment administration page yet.
+      
+    // View enough comments on the administration overview form so that it spans several pages.
+//    $this->drupalGet('');
+//    $node1 = $this->drupalCreateNode(array('type' => 'article'));
+//    for ($i = 1; $i <= 49 ; $i++) {
+//      $this->postComment($node1, 'simpletest comment '. $i, $this->randomName());
+//    }
+//    // By using another node, we can circumvent the validation checks in postComment().
+//    // We post two additional comments o trigger the pager.
+//    $node1 = $this->drupalCreateNode(array('type' => 'article'));
+//    for ($i = 1; $i <= 2 ; $i++) {
+//      $this->postComment($node1, $this->randomName(), $this->randomName());
+//    }
+//    $this->drupalGet('admin/content/comment');
+//    $this->assertText(t(' '), $this->drupalGetContent());
+//    
+//    
+    $this->drupalLogout();
+  }
+}
+
