1 comment.test CommentFieldsTest::testCommentEnable()

Tests that comment module works when enabled after a content module.

File

core/modules/comment/tests/comment.test, line 2129
Tests for the Comment module.

Class

CommentFieldsTest
Tests fields on comments.

Code

function testCommentEnable() {
  // Create a user to do module administration.
  $this->admin_user = $this->backdropCreateUser(array('access administration pages', 'administer modules'));
  $this->backdropLogin($this->admin_user);

  // Disable the comment module.
  $edit = array();
  $edit['modules[Comments][comment][enable]'] = FALSE;
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->resetAll();
  $this->assertFalse(module_exists('comment'), 'Comment module disabled.');

  // Enable core content type module: book.
  $edit = array();
  $edit['modules[System][book][enable]'] = 'book';
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->resetAll();

  // Now enable the comment module.
  $edit = array();
  $edit['modules[Comments][comment][enable]'] = 'comment';
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->resetAll();
  $this->assertTrue(module_exists('comment'), 'Comment module enabled.');

  // Create nodes of each type.
  $book_node = $this->backdropCreateNode(array('type' => 'book'));

  $this->backdropLogout();

  // Try to post a comment on each node. A failure will be triggered if the
  // comment body is missing on one of these forms, due to postComment()
  // asserting that the body is actually posted correctly.
  $this->web_user = $this->backdropCreateUser(array('access content', 'access comments', 'post comments', 'skip comment approval'));
  $this->backdropLogin($this->web_user);
  $this->postComment($book_node, $this->randomName(), '');
}