Commit 45b49610 authored by jhodgdon's avatar jhodgdon

Issue #1742602 by xjm, lazysoundsystem: Remove t() from test assertions in comment module

parent b5acb7bc
......@@ -31,25 +31,25 @@ function testCommentPublishUnpublishActions() {
// Unpublish a comment (direct form: doesn't actually save the comment).
comment_unpublish_action($comment);
$this->assertEqual($comment->status, COMMENT_NOT_PUBLISHED, t('Comment was unpublished'));
$this->assertWatchdogMessage('Unpublished comment %subject.', array('%subject' => $subject), t('Found watchdog message'));
$this->assertEqual($comment->status, COMMENT_NOT_PUBLISHED, 'Comment was unpublished');
$this->assertWatchdogMessage('Unpublished comment %subject.', array('%subject' => $subject), 'Found watchdog message');
$this->clearWatchdog();
// Unpublish a comment (indirect form: modify the comment in the database).
comment_unpublish_action(NULL, array('cid' => $comment->cid));
$this->assertEqual(comment_load($comment->cid)->status, COMMENT_NOT_PUBLISHED, t('Comment was unpublished'));
$this->assertWatchdogMessage('Unpublished comment %subject.', array('%subject' => $subject), t('Found watchdog message'));
$this->assertEqual(comment_load($comment->cid)->status, COMMENT_NOT_PUBLISHED, 'Comment was unpublished');
$this->assertWatchdogMessage('Unpublished comment %subject.', array('%subject' => $subject), 'Found watchdog message');
// Publish a comment (direct form: doesn't actually save the comment).
comment_publish_action($comment);
$this->assertEqual($comment->status, COMMENT_PUBLISHED, t('Comment was published'));
$this->assertWatchdogMessage('Published comment %subject.', array('%subject' => $subject), t('Found watchdog message'));
$this->assertEqual($comment->status, COMMENT_PUBLISHED, 'Comment was published');
$this->assertWatchdogMessage('Published comment %subject.', array('%subject' => $subject), 'Found watchdog message');
$this->clearWatchdog();
// Publish a comment (indirect form: modify the comment in the database).
comment_publish_action(NULL, array('cid' => $comment->cid));
$this->assertEqual(comment_load($comment->cid)->status, COMMENT_PUBLISHED, t('Comment was published'));
$this->assertWatchdogMessage('Published comment %subject.', array('%subject' => $subject), t('Found watchdog message'));
$this->assertEqual(comment_load($comment->cid)->status, COMMENT_PUBLISHED, 'Comment was published');
$this->assertWatchdogMessage('Published comment %subject.', array('%subject' => $subject), 'Found watchdog message');
$this->clearWatchdog();
}
......@@ -65,7 +65,7 @@ function testCommentPublishUnpublishActions() {
*/
function assertWatchdogMessage($watchdog_message, $variables, $message) {
$status = (bool) db_query_range("SELECT 1 FROM {watchdog} WHERE message = :message AND variables = :variables", 0, 1, array(':message' => $watchdog_message, ':variables' => serialize($variables)))->fetchField();
return $this->assert($status, $message);
return $this->assert($status, format_string('@message', array('@message'=> $message)));
}
/**
......
......@@ -40,7 +40,7 @@ function testAnonymous() {
// Post anonymous comment without contact info.
$anonymous_comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($anonymous_comment1), t('Anonymous comment without contact info found.'));
$this->assertTrue($this->commentExists($anonymous_comment1), 'Anonymous comment without contact info found.');
// Allow contact info.
$this->drupalLogin($this->admin_user);
......@@ -49,15 +49,15 @@ function testAnonymous() {
// Attempt to edit anonymous comment.
$this->drupalGet('comment/' . $anonymous_comment1->id . '/edit');
$edited_comment = $this->postComment(NULL, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($edited_comment, FALSE), t('Modified reply found.'));
$this->assertTrue($this->commentExists($edited_comment, FALSE), 'Modified reply found.');
$this->drupalLogout();
// Post anonymous comment with contact info (optional).
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.'));
$this->assertTrue($this->commentContactInfoAvailable(), 'Contact information available.');
$anonymous_comment2 = $this->postComment($this->node, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($anonymous_comment2), t('Anonymous comment with contact info (optional) found.'));
$this->assertTrue($this->commentExists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.');
// Ensure anonymous users cannot post in the name of registered users.
$langcode = LANGUAGE_NOT_SPECIFIED;
......@@ -77,41 +77,42 @@ function testAnonymous() {
// Try to post comment with contact info (required).
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.'));
$this->assertTrue($this->commentContactInfoAvailable(), 'Contact information available.');
$anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
$this->assertText(t('E-mail field is required.'), t('E-mail required.')); // Name should have 'Anonymous' for value by default.
$this->assertFalse($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) not found.'));
// Name should have 'Anonymous' for value by default.
$this->assertText(t('E-mail field is required.'), 'E-mail required.');
$this->assertFalse($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) not found.');
// Post comment with contact info (required).
$author_name = $this->randomName();
$author_mail = $this->randomName() . '@example.com';
$anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), array('name' => $author_name, 'mail' => $author_mail));
$this->assertTrue($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) found.'));
$this->assertTrue($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) found.');
// Make sure the user data appears correctly when editing the comment.
$this->drupalLogin($this->admin_user);
$this->drupalGet('comment/' . $anonymous_comment3->id . '/edit');
$this->assertRaw($author_name, t("The anonymous user's name is correct when editing the comment."));
$this->assertRaw($author_mail, t("The anonymous user's e-mail address is correct when editing the comment."));
$this->assertRaw($author_name, "The anonymous user's name is correct when editing the comment.");
$this->assertRaw($author_mail, "The anonymous user's e-mail address is correct when editing the comment.");
// Unpublish comment.
$this->performCommentOperation($anonymous_comment3, 'unpublish');
$this->drupalGet('admin/content/comment/approval');
$this->assertRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was unpublished.'));
$this->assertRaw('comments[' . $anonymous_comment3->id . ']', 'Comment was unpublished.');
// Publish comment.
$this->performCommentOperation($anonymous_comment3, 'publish', TRUE);
$this->drupalGet('admin/content/comment');
$this->assertRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was published.'));
$this->assertRaw('comments[' . $anonymous_comment3->id . ']', 'Comment was published.');
// Delete comment.
$this->performCommentOperation($anonymous_comment3, 'delete');
$this->drupalGet('admin/content/comment');
$this->assertNoRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was deleted.'));
$this->assertNoRaw('comments[' . $anonymous_comment3->id . ']', 'Comment was deleted.');
$this->drupalLogout();
// Reset.
......@@ -125,14 +126,14 @@ function testAnonymous() {
// NOTE: if authenticated user has permission to post comments, then a
// "Login or register to post comments" type link may be shown.
$this->drupalGet('node/' . $this->node->nid);
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', t('Comments were not displayed.'));
$this->assertNoLink('Add new comment', t('Link to add comment was found.'));
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.');
// Attempt to view node-comment form while disallowed.
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertText('You are not authorized to post comments', t('Error attempting to post comment.'));
$this->assertNoFieldByName('subject', '', t('Subject field not found.'));
$this->assertNoFieldByName("comment_body[$langcode][0][value]", '', t('Comment field not found.'));
$this->assertText('You are not authorized to post comments', 'Error attempting to post comment.');
$this->assertNoFieldByName('subject', '', 'Subject field not found.');
$this->assertNoFieldByName("comment_body[$langcode][0][value]", '', 'Comment field not found.');
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
......@@ -140,9 +141,9 @@ function testAnonymous() {
'skip comment approval' => FALSE,
));
$this->drupalGet('node/' . $this->node->nid);
$this->assertPattern('@<h2[^>]*>Comments</h2>@', t('Comments were displayed.'));
$this->assertLink('Log in', 1, t('Link to log in was found.'));
$this->assertLink('register', 1, t('Link to register was found.'));
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 1, 'Link to log in was found.');
$this->assertLink('register', 1, 'Link to register was found.');
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => FALSE,
......@@ -150,12 +151,12 @@ function testAnonymous() {
'skip comment approval' => TRUE,
));
$this->drupalGet('node/' . $this->node->nid);
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', t('Comments were not displayed.'));
$this->assertFieldByName('subject', '', t('Subject field found.'));
$this->assertFieldByName("comment_body[$langcode][0][value]", '', t('Comment field found.'));
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertFieldByName('subject', '', 'Subject field found.');
$this->assertFieldByName("comment_body[$langcode][0][value]", '', 'Comment field found.');
$this->drupalGet('comment/reply/' . $this->node->nid . '/' . $anonymous_comment3->id);
$this->assertText('You are not authorized to view comments', t('Error attempting to post reply.'));
$this->assertNoText($author_name, t('Comment not displayed.'));
$this->assertText('You are not authorized to view comments', 'Error attempting to post reply.');
$this->assertNoText($author_name, 'Comment not displayed.');
}
}
......@@ -42,7 +42,7 @@ function testApprovalAdminInterface() {
$subject = $this->randomName();
$body = $this->randomName();
$this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.'));
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), 'Comment requires approval.');
// Get unapproved comment id.
$this->drupalLogin($this->admin_user);
......@@ -50,7 +50,7 @@ function testApprovalAdminInterface() {
$anonymous_comment4 = entity_create('comment', array('id' => $anonymous_comment4, 'subject' => $subject, 'comment' => $body));
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), t('Anonymous comment was not published.'));
$this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');
// Approve comment.
$this->drupalLogin($this->admin_user);
......@@ -58,7 +58,7 @@ function testApprovalAdminInterface() {
$this->drupalLogout();
$this->drupalGet('node/' . $this->node->nid);
$this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.'));
$this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.');
// Post 2 anonymous comments without contact info.
$comments[] = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
......@@ -67,13 +67,13 @@ function testApprovalAdminInterface() {
// Publish multiple comments in one operation.
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/content/comment/approval');
$this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), t('Two unapproved comments waiting for approval.'));
$this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), 'Two unapproved comments waiting for approval.');
$edit = array(
"comments[{$comments[0]->id}]" => 1,
"comments[{$comments[1]->id}]" => 1,
);
$this->drupalPost(NULL, $edit, t('Update'));
$this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), t('All comments were approved.'));
$this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), 'All comments were approved.');
// Delete multiple comments in one operation.
$edit = array(
......@@ -83,9 +83,9 @@ function testApprovalAdminInterface() {
"comments[{$anonymous_comment4->id}]" => 1,
);
$this->drupalPost(NULL, $edit, t('Update'));
$this->assertText(t('Are you sure you want to delete these comments and all their children?'), t('Confirmation required.'));
$this->assertText(t('Are you sure you want to delete these comments and all their children?'), 'Confirmation required.');
$this->drupalPost(NULL, $edit, t('Delete comments'));
$this->assertText(t('No comments available.'), t('All comments were deleted.'));
$this->assertText(t('No comments available.'), 'All comments were deleted.');
}
/**
......@@ -106,7 +106,7 @@ function testApprovalNodeInterface() {
$subject = $this->randomName();
$body = $this->randomName();
$this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.'));
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), 'Comment requires approval.');
// Get unapproved comment id.
$this->drupalLogin($this->admin_user);
......@@ -114,19 +114,19 @@ function testApprovalNodeInterface() {
$anonymous_comment4 = entity_create('comment', array('id' => $anonymous_comment4, 'subject' => $subject, 'comment' => $body));
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), t('Anonymous comment was not published.'));
$this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');
// Approve comment.
$this->drupalLogin($this->admin_user);
$this->drupalGet('comment/1/approve');
$this->assertResponse(403, t('Forged comment approval was denied.'));
$this->assertResponse(403, 'Forged comment approval was denied.');
$this->drupalGet('comment/1/approve', array('query' => array('token' => 'forged')));
$this->assertResponse(403, t('Forged comment approval was denied.'));
$this->assertResponse(403, 'Forged comment approval was denied.');
$this->drupalGet('node/' . $this->node->nid);
$this->clickLink(t('approve'));
$this->drupalLogout();
$this->drupalGet('node/' . $this->node->nid);
$this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.'));
$this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.');
}
}
......@@ -30,7 +30,7 @@ function testRecentCommentBlock() {
'blocks[comment_recent][region]' => 'sidebar_first',
);
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this->assertText(t('The block settings have been updated.'), t('Block saved to first sidebar region.'));
$this->assertText(t('The block settings have been updated.'), 'Block saved to first sidebar region.');
// Set block title and variables.
$block = array(
......@@ -38,7 +38,7 @@ function testRecentCommentBlock() {
'comment_block_count' => 2,
);
$this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
$this->assertText(t('The block configuration has been saved.'), 'Block saved.');
// Add some test comments, one without a subject.
$comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
......@@ -53,20 +53,20 @@ function testRecentCommentBlock() {
// posting a node from a node form.
cache_invalidate(array('content' => TRUE));
$this->drupalGet('');
$this->assertNoText($block['title'], t('Block was not found.'));
$this->assertNoText($block['title'], 'Block was not found.');
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments'));
// Test that a user with the 'access comments' permission can see the
// block.
$this->drupalLogin($this->web_user);
$this->drupalGet('');
$this->assertText($block['title'], t('Block was found.'));
$this->assertText($block['title'], 'Block was found.');
// Test the only the 2 latest comments are shown and in the proper order.
$this->assertNoText($comment1->subject, t('Comment not found in block.'));
$this->assertText($comment2->subject, t('Comment found in block.'));
$this->assertText($comment3->comment, t('Comment found in block.'));
$this->assertTrue(strpos($this->drupalGetContent(), $comment3->comment) < strpos($this->drupalGetContent(), $comment2->subject), t('Comments were ordered correctly in block.'));
$this->assertNoText($comment1->subject, 'Comment not found in block.');
$this->assertText($comment2->subject, 'Comment found in block.');
$this->assertText($comment3->comment, 'Comment found in block.');
$this->assertTrue(strpos($this->drupalGetContent(), $comment3->comment) < strpos($this->drupalGetContent(), $comment2->subject), 'Comments were ordered correctly in block.');
// Set the number of recent comments to show to 10.
$this->drupalLogout();
......@@ -75,29 +75,29 @@ function testRecentCommentBlock() {
'comment_block_count' => 10,
);
$this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
$this->assertText(t('The block configuration has been saved.'), 'Block saved.');
// Post an additional comment.
$comment4 = $this->postComment($this->node, $this->randomName(), $this->randomName());
// Test that all four comments are shown.
$this->assertText($comment1->subject, t('Comment found in block.'));
$this->assertText($comment2->subject, t('Comment found in block.'));
$this->assertText($comment3->comment, t('Comment found in block.'));
$this->assertText($comment1->subject, 'Comment found in block.');
$this->assertText($comment2->subject, 'Comment found in block.');
$this->assertText($comment3->comment, 'Comment found in block.');
$this->assertText($comment4->subject, t('Comment found in block.'));
// Test that links to comments work when comments are across pages.
$this->setCommentsPerPage(1);
$this->drupalGet('');
$this->clickLink($comment1->subject);
$this->assertText($comment1->subject, t('Comment link goes to correct page.'));
$this->assertText($comment1->subject, 'Comment link goes to correct page.');
$this->drupalGet('');
$this->clickLink($comment2->subject);
$this->assertText($comment2->subject, t('Comment link goes to correct page.'));
$this->assertText($comment2->subject, 'Comment link goes to correct page.');
$this->clickLink($comment4->subject);
$this->assertText($comment4->subject, t('Comment link goes to correct page.'));
$this->assertText($comment4->subject, 'Comment link goes to correct page.');
// Check that when viewing a comment page from a link to the comment, that
// rel="canonical" is added to the head of the document.
$this->assertRaw('<link rel="canonical"', t('Canonical URL was found in the HTML head'));
$this->assertRaw('<link rel="canonical"', 'Canonical URL was found in the HTML head');
}
}
......@@ -35,13 +35,13 @@ function testCommentRebuild() {
$comment_text = $this->randomName();
$comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
$comment_loaded = comment_load($comment->id);
$this->assertTrue($this->commentExists($comment), t('Comment found.'));
$this->assertTrue($this->commentExists($comment), 'Comment found.');
// Add the property to the content array and then see if it still exists on build.
$comment_loaded->content['test_property'] = array('#value' => $this->randomString());
$built_content = comment_view($comment_loaded, $this->node);
// This means that the content was rebuilt as the added test property no longer exists.
$this->assertFalse(isset($built_content['test_property']), t('Comment content was emptied before being built.'));
$this->assertFalse(isset($built_content['test_property']), 'Comment content was emptied before being built.');
}
}
......@@ -30,7 +30,7 @@ function testCommentDefaultFields() {
// 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)));
$this->assertTrue(isset($instances['comment_node_' . $type_name]['comment_body']), format_string('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']);
......@@ -38,7 +38,7 @@ function testCommentDefaultFields() {
// 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'));
$this->assertTrue(empty($field), 'The comment_body field was deleted');
// Create a new content type.
$type_name = 'test_node_type_2';
......@@ -47,9 +47,9 @@ function testCommentDefaultFields() {
// 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'));
$this->assertTrue($field, '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)));
$this->assertTrue(isset($instances['comment_node_' . $type_name]['comment_body']), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
}
/**
......@@ -65,7 +65,7 @@ function testCommentEnable() {
$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.'));
$this->assertFalse(module_exists('comment'), 'Comment module disabled.');
// Enable core content type modules (book, and poll).
$edit = array();
......@@ -78,7 +78,7 @@ function testCommentEnable() {
$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.'));
$this->assertTrue(module_exists('comment'), 'Comment module enabled.');
// Create nodes of each type.
$book_node = $this->drupalCreateNode(array('type' => 'book'));
......
......@@ -34,7 +34,7 @@ function testCommentInterface() {
$comment_text = $this->randomName();
$comment = $this->postComment($this->node, $comment_text);
$comment_loaded = comment_load($comment->id);
$this->assertTrue($this->commentExists($comment), t('Comment found.'));
$this->assertTrue($this->commentExists($comment), 'Comment found.');
// Set comments to have subject and preview to required.
$this->drupalLogout();
......@@ -49,12 +49,12 @@ function testCommentInterface() {
$comment_text = $this->randomName();
$comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
$comment_loaded = comment_load($comment->id);
$this->assertTrue($this->commentExists($comment), t('Comment found.'));
$this->assertTrue($this->commentExists($comment), 'Comment found.');
// Check comment display.
$this->drupalGet('node/' . $this->node->nid . '/' . $comment->id);
$this->assertText($subject_text, t('Individual comment subject found.'));
$this->assertText($comment_text, t('Individual comment body found.'));
$this->assertText($subject_text, 'Individual comment subject found.');
$this->assertText($comment_text, 'Individual comment body found.');
// Set comments to have subject and preview to optional.
$this->drupalLogout();
......@@ -66,20 +66,20 @@ function testCommentInterface() {
$this->drupalGet('comment/' . $comment->id . '/edit');
$comment = $this->postComment(NULL, $comment->comment, $comment->subject, array('name' => ''));
$comment_loaded = comment_load($comment->id);
$this->assertTrue(empty($comment_loaded->name) && $comment_loaded->uid == 0, t('Comment author successfully changed to anonymous.'));
$this->assertTrue(empty($comment_loaded->name) && $comment_loaded->uid == 0, 'Comment author successfully changed to anonymous.');
// Test changing the comment author to an unverified user.
$random_name = $this->randomName();
$this->drupalGet('comment/' . $comment->id . '/edit');
$comment = $this->postComment(NULL, $comment->comment, $comment->subject, array('name' => $random_name));
$this->drupalGet('node/' . $this->node->nid);
$this->assertText($random_name . ' (' . t('not verified') . ')', t('Comment author successfully changed to an unverified user.'));
$this->assertText($random_name . ' (' . t('not verified') . ')', 'Comment author successfully changed to an unverified user.');
// Test changing the comment author to a verified user.
$this->drupalGet('comment/' . $comment->id . '/edit');
$comment = $this->postComment(NULL, $comment->comment, $comment->subject, array('name' => $this->web_user->name));
$comment_loaded = comment_load($comment->id);
$this->assertTrue($comment_loaded->name == $this->web_user->name && $comment_loaded->uid == $this->web_user->uid, t('Comment author successfully changed to a registered user.'));
$this->assertTrue($comment_loaded->name == $this->web_user->name && $comment_loaded->uid == $this->web_user->uid, 'Comment author successfully changed to a registered user.');
$this->drupalLogout();
......@@ -87,38 +87,38 @@ function testCommentInterface() {
// subject though field enabled.
$this->drupalLogin($this->web_user);
$this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
$this->assertText($subject_text, t('Individual comment-reply subject found.'));
$this->assertText($comment_text, t('Individual comment-reply body found.'));
$this->assertText($subject_text, 'Individual comment-reply subject found.');
$this->assertText($comment_text, 'Individual comment-reply body found.');
$reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
$reply_loaded = comment_load($reply->id);
$this->assertTrue($this->commentExists($reply, TRUE), t('Reply found.'));
$this->assertEqual($comment->id, $reply_loaded->pid, t('Pid of a reply to a comment is set correctly.'));
$this->assertEqual(rtrim($comment_loaded->thread, '/') . '.00/', $reply_loaded->thread, t('Thread of reply grows correctly.'));
$this->assertTrue($this->commentExists($reply, TRUE), 'Reply found.');
$this->assertEqual($comment->id, $reply_loaded->pid, 'Pid of a reply to a comment is set correctly.');
$this->assertEqual(rtrim($comment_loaded->thread, '/') . '.00/', $reply_loaded->thread, 'Thread of reply grows correctly.');
// Second reply to comment #3 creating comment #4.
$this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
$this->assertText($subject_text, t('Individual comment-reply subject found.'));
$this->assertText($comment_text, t('Individual comment-reply body found.'));
$this->assertText($comment_text, 'Individual comment-reply body found.');
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
$reply_loaded = comment_load($reply->id);
$this->assertTrue($this->commentExists($reply, TRUE), t('Second reply found.'));
$this->assertEqual(rtrim($comment_loaded->thread, '/') . '.01/', $reply_loaded->thread, t('Thread of second reply grows correctly.'));
$this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.');
$this->assertEqual(rtrim($comment_loaded->thread, '/') . '.01/', $reply_loaded->thread, 'Thread of second reply grows correctly.');
// Edit reply.
$this->drupalGet('comment/' . $reply->id . '/edit');
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
$this->assertTrue($this->commentExists($reply, TRUE), t('Modified reply found.'));
$this->assertTrue($this->commentExists($reply, TRUE), 'Modified reply found.');
// Correct link count
$this->drupalGet('node');
$this->assertRaw('4 comments', t('Link to the 4 comments exist.'));
$this->assertRaw('4 comments', 'Link to the 4 comments exist.');
// Confirm a new comment is posted to the correct page.
$this->setCommentsPerPage(2);
$comment_new_page = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
$this->assertTrue($this->commentExists($comment_new_page), t('Page one exists. %s'));
$this->assertTrue($this->commentExists($comment_new_page), 'Page one exists. %s');
$this->drupalGet('node/' . $this->node->nid, array('query' => array('page' => 1)));
$this->assertTrue($this->commentExists($reply, TRUE), t('Page two exists. %s'));
$this->assertTrue($this->commentExists($reply, TRUE), 'Page two exists. %s');
$this->setCommentsPerPage(50);
// Attempt to reply to an unpublished comment.
......@@ -129,24 +129,24 @@ function testCommentInterface() {
// Attempt to post to node with comments disabled.
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_HIDDEN));
$this->assertTrue($this->node, t('Article node created.'));
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertText('This discussion is closed', t('Posting to node with comments disabled'));
$this->assertNoField('edit-comment', t('Comment body field found.'));
$this->assertText('This discussion is closed', 'Posting to node with comments disabled');
$this->assertNoField('edit-comment', 'Comment body field found.');
// Attempt to post to node with read-only comments.
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_CLOSED));
$this->assertTrue($this->node, t('Article node created.'));
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertText('This discussion is closed', t('Posting to node with comments read-only'));
$this->assertNoField('edit-comment', t('Comment body field found.'));
$this->assertText('This discussion is closed', 'Posting to node with comments read-only');
$this->assertNoField('edit-comment', 'Comment body field found.');
// Attempt to post to node with comments enabled (check field names etc).
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_OPEN));
$this->assertTrue($this->node, t('Article node created.'));
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertNoText('This discussion is closed', t('Posting to node with comments enabled'));
$this->assertField('edit-comment-body-' . $langcode . '-0-value', t('Comment body field found.'));
$this->assertNoText('This discussion is closed', 'Posting to node with comments enabled');
$this->assertField('edit-comment-body-' . $langcode . '-0-value', 'Comment body field found.');
// Delete comment and make sure that reply is also removed.
$this->drupalLogout();
......@@ -155,8 +155,8 @@ function testCommentInterface() {
$this->deleteComment($comment_new_page);
$this->drupalGet('node/' . $this->node->nid);
$this->assertFalse($this->commentExists($comment), t('Comment not found.'));
$this->assertFalse($this->commentExists($reply, TRUE), t('Reply not found.'));
$this->assertFalse($this->commentExists($comment), 'Comment not found.');
$this->assertFalse($this->commentExists($reply, TRUE), 'Reply not found.');
// Enabled comment form on node page.
$this->drupalLogin($this->admin_user);
......@@ -167,7 +167,7 @@ function testCommentInterface() {
$this->drupalLogin($this->web_user);
$this->drupalGet('node/' . $this->node->nid);
$form_comment = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
$this->assertTrue($this->commentExists($form_comment), t('Form comment found.'));
$this->assertTrue($this->commentExists($form_comment), 'Form comment found.');
// Disable comment form on node page.
$this->drupalLogout();
......@@ -188,7 +188,7 @@ public function testCommentNewCommentsIndicator() {
$this->assertNoLink(t('@count new comments', array('@count' => 0)));
$this->assertLink(t('Read more'));
$count = $this->xpath('//div[@id=:id]/div[@class=:class]/ul/li', array(':id' => 'node-' . $this->node->nid, ':class' => 'link-wrapper'));
$this->assertTrue(count($count) == 1, t('One child found'));
$this->assertTrue(count($count) == 1, 'One child found');
// Create a new comment. This helper function may be run with different
// comment settings so use comment_save() to avoid complex setup.
......@@ -212,8 +212,8 @@ public function testCommentNewCommentsIndicator() {
$this->drupalGet('node');
$this->assertLink(t('1 new comment'));
$this->clickLink(t('1 new comment'));
$this->assertRaw('<a id="new"></a>', t('Found "new" marker.'));
$this->assertTrue($this->xpath('//a[@id=:new]/following-sibling::a[1][@id=:comment_id]', array(':new' => 'new', ':comment_id' => 'comment-1')), t('The "new" anchor is positioned at the right comment.'));
$this->assertRaw('<a id="new"></a>', 'Found "new" marker.');
$this->assertTrue($this->xpath('//a[@id=:new]/following-sibling::a[1][@id=:comment_id]', array(':new' => 'new', ':comment_id' => 'comment-1')), 'The "new" anchor is positioned at the right comment.');
// Test if "new comment" link is correctly removed.
$this->drupalGet('node');
......@@ -350,10 +350,10 @@ function testCommentNodeCommentStatistics() {
// Checks the initial values of node comment statistics with no comment.
$node = node_load($this->node->nid);
$this->assertEqual($node->last_comment_timestamp, $this->node->created, t('The initial value of node last_comment_timestamp is the node created date.'));
$this->assertEqual($node->last_comment_name, NULL, t('The initial value of node last_comment_name is NULL.'));
$this->assertEqual($node->last_comment_uid, $this->web_user->uid, t('The initial value of node last_comment_uid is the node uid.'));
$this->assertEqual($node->comment_count, 0, t('The initial value of node comment_count is zero.'));
$this->assertEqual($node->last_comment_timestamp, $this->node->created, 'The initial value of node last_comment_timestamp is the node created date.');
$this->assertEqual($node->last_comment_name, NULL, 'The initial value of node last_comment_name is NULL.');
$this->assertEqual($node->last_comment_uid, $this->web_user->uid, 'The initial value of node last_comment_uid is the node uid.');
$this->assertEqual($node->comment_count, 0, 'The initial value of node comment_count is zero.');
// Post comment #1 as web_user2.
$this->drupalLogin($this->web_user2);
......@@ -364,9 +364,9 @@ function testCommentNodeCommentStatistics() {
// Checks the new values of node comment statistics with comment #1.
// The node needs to be reloaded with a node_load_multiple cache reset.
$node = node_load($this->node->nid, TRUE);
$this->assertEqual($node->last_comment_name, NULL, t('The value of node last_comment_name is NULL.'));
$this->assertEqual($node->last_comment_uid, $this->web_user2->uid, t('The value of node last_comment_uid is the comment #1 uid.'));
$this->assertEqual($node->comment_count, 1, t('The value of node comment_count is 1.'));
$this->assertEqual($node->last_comment_name, NULL, 'The value of node last_comment_name is NULL.');
$this->assertEqual($node->last_comment_uid, $this->web_user2->uid, 'The value of node last_comment_uid is the comment #1 uid.');
$this->assertEqual($node->comment_count, 1, 'The value of node comment_count is 1.');
// Prepare for anonymous comment submission (comment approval enabled).