Index: modules/comment/comment.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v
retrieving revision 1.95
diff -u -p -r1.95 comment.test
--- modules/comment/comment.test	9 Dec 2010 02:16:21 -0000	1.95
+++ modules/comment/comment.test	12 Dec 2010 03:29:05 -0000
@@ -1478,3 +1478,111 @@ class CommentActionsTestCase extends Com
     db_truncate('watchdog')->execute();
   }
 }
+
+/**
+ * Test that comment module works after being enabled after a content module.
+ */
+class CommentEnableTest extends CommentHelperCase {
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Comment enable test',
+      'description' => 'Test that comment module works after being enabled after a content module.',
+      'group' => 'Comment',
+    );
+  }
+
+  function setUp() {
+    // Do not call parent::setUp() because we selectively enable modules.
+    DrupalWebTestCase::setUp();
+  }
+
+  /**
+   * Test that comment module works after being enabled after a content module.
+   */
+  function testCommentEnable() {
+    // Create a user to do module administration.
+    $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
+    $this->drupalLogin($this->admin_user);
+
+    // Enable core content type modules (blog, book, and poll).
+    $edit = array();
+    $edit['modules[Core][blog][enable]'] = 'blog';
+    $edit['modules[Core][book][enable]'] = 'book';
+    $edit['modules[Core][poll][enable]'] = 'poll';
+    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
+    $this->resetAll();
+
+    // Now enable the comment module.
+    $edit = array();
+    $edit['modules[Core][comment][enable]'] = 'comment';
+    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
+    $this->resetAll();
+    $this->assertTrue(module_exists('comment'), t('Comment module installed.'));
+
+    // Create nodes of each type.
+    $blog_node = $this->drupalCreateNode(array('type' => 'blog'));
+    $book_node = $this->drupalCreateNode(array('type' => 'book'));
+    $poll_node = $this->drupalCreateNode(array('type' => 'poll', 'active' => 1, 'runtime' => 0, 'choice' => array(array('chtext' => ''))));
+
+    $this->drupalLogout();
+
+    // Try to post a comment on each node. An failure will be triggered if the
+    // comment body is missing on one of these forms.
+    $this->web_user = $this->drupalCreateUser(array('access content', 'access comments', 'post comments', 'skip comment approval'));
+    $this->drupalLogin($this->web_user);
+    $this->postComment($blog_node, $this->randomName(), $this->randomName());
+    $this->postComment($book_node, $this->randomName(), $this->randomName());
+    $this->postComment($poll_node, $this->randomName(), $this->randomName());
+  }
+}
+
+/**
+ * Test fields on comments.
+ */
+class CommentFields extends CommentHelperCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Comment fields',
+      'description' => 'Tests fields on comments.',
+      'group' => 'Comment',
+    );
+  }
+
+  /**
+   * Tests that the default 'comment_body' field is correctly added.
+   */
+  function testCommentDefaultFields() {
+    // Do not make assumptions on default node types created by the test
+    // install profile, and create our own.
+    $this->drupalCreateContentType(array('type' => 'test_node_type'));
+
+    // Check that the 'comment_body' field is present on all comment bundles.
+    $instances = field_info_instances('comment');
+    foreach (node_type_get_types() as $type_name => $info) {
+      $this->assertTrue(isset($instances['comment_node_' . $type_name]['comment_body']), t('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
+
+      // Delete the instance along the way.
+      field_delete_instance($instances['comment_node_' . $type_name]['comment_body']);
+    }
+
+    // @todo simulate http://drupal.org/node/915906
+    field_delete_field('comment_body');
+
+    // Check that the 'comment_body' field is deleted.
+    $field = field_info_field('comment_body');
+    $this->assertTrue(empty($field), t('The comment_body field was deleted'));
+
+    // Create a new content type.
+    $type_name = 'test_node_type_2';
+    $this->drupalCreateContentType(array('type' => $type_name));
+
+    // Check that the 'comment_body' field exists and has an instance on the
+    // new comment bundle.
+    $field = field_info_field('comment_body');
+    $this->assertTrue($field, t('The comment_body field exists'));
+    $instances = field_info_instances('comment');
+    $this->assertTrue(isset($instances['comment_node_' . $type_name]['comment_body']), t('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
+  }
+}