diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-12-18 01:50:16 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-12-18 01:50:16 +0000 |
commit | d12eba1705dfa3c6f7da93f81c403b33de8fd8fc (patch) | |
tree | a369f5ee79a2386d817f421d2bb3d43c79721695 /modules/comment/comment.test | |
parent | a686c81335caf84c7fdb3fb4a4b5e950266441c0 (diff) | |
download | brdo-d12eba1705dfa3c6f7da93f81c403b33de8fd8fc.tar.gz brdo-d12eba1705dfa3c6f7da93f81c403b33de8fd8fc.tar.bz2 |
- Patch #890128 by carlos8f, sumitk: comment body missing if comment module enabled after a content type module.
Diffstat (limited to 'modules/comment/comment.test')
-rw-r--r-- | modules/comment/comment.test | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/modules/comment/comment.test b/modules/comment/comment.test index 45d6631bd..fbef5d7a8 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -1478,3 +1478,96 @@ class CommentActionsTestCase extends CommentHelperCase { db_truncate('watchdog')->execute(); } } + +/** + * Test fields on comments. + */ +class CommentFieldsTest 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']); + } + + // 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))); + } + + /** + * Test that comment module works when 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); + + // Disable the comment module. + $edit = array(); + $edit['modules[Core][comment][enable]'] = FALSE; + $this->drupalPost('admin/modules', $edit, t('Save configuration')); + $this->resetAll(); + $this->assertFalse(module_exists('comment'), t('Comment module disabled.')); + + // 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 enabled.')); + + // 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. 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->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()); + } +} |