| 1 comment.test | CommentFieldsTest::testCommentEnable() |
Tests that comment module works when enabled after a content module.
File
- core/
modules/ comment/ tests/ comment.test, line 2136 - 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',
'administer fields',
'administer content types',
'administer comment settings',
));
$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.');
// Check that comments are not enabled by default.
$this->backdropGet('admin/structure/types/manage/book');
$this->assertNoFieldChecked('edit-comment-enabled', 'Comments not enabled on a new content type by default.');
$this->assertNoLink(t('Comment fields'));
$this->assertNoLink(t('Comment display'));
// Enable comments on the book content type.
$edit = array('comment_enabled' => TRUE);
$this->backdropPost(NULL, $edit, t('Save content type'));
$this->backdropGet('admin/structure/types/manage/book');
$this->assertFieldChecked('edit-comment-enabled', 'Comments are enabled after updating content type.');
$this->assertLink(t('Comment fields'));
$this->assertLink(t('Comment display'));
// 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(), '');
}