function CommentNotifyTestCase::postCommentNotifyComment in Comment Notify 6
Same name and namespace in other branches
- 7 comment_notify.test \CommentNotifyTestCase::postCommentNotifyComment()
Post comment.
Parameters
object $node Node to post comment on.:
string $subject Comment subject.:
string $comment Comment body.:
boolean $preview Should preview be required.:
mixed $contact Set to NULL for no contact info, TRUE to ignore success checking, and array of values to set contact info.:
1 call to CommentNotifyTestCase::postCommentNotifyComment()
- CommentNotifyTestCase::testCommentNotifyAnonymousUserFunctionalTest in ./
comment_notify.test - Test various behaviors for anonymous users.
File
- ./
comment_notify.test, line 124
Class
Code
function postCommentNotifyComment($node, $subject, $comment, $preview = TRUE, $notify, $contact = NULL) {
$edit = array();
$edit['subject'] = $subject;
$edit['comment'] = $comment;
if ($notify !== NULL && is_array($notify)) {
$edit += $notify;
}
if ($contact !== NULL && is_array($contact)) {
$edit += $contact;
}
if ($node !== NULL) {
$this
->drupalGet('comment/reply/' . $node->nid);
}
if ($preview) {
$this
->assertNoFieldByName('op', t('Save'), t('Save button not found.'));
// Preview required so no save button should be found.
$this
->drupalPost(NULL, $edit, t('Preview'));
}
$this
->drupalPost(NULL, $edit, t('Save'));
$match = array();
// Get comment ID
preg_match('/#comment-([^"]+)/', $this
->getURL(), $match);
// Get comment.
if (!empty($match[1])) {
// If true then attempting to find error message.
if ($subject) {
$this
->assertText($subject, 'Comment subject posted.');
}
$this
->assertText($comment, 'Comment body posted.');
$this
->assertTrue(!empty($match) && !empty($match[1]), t('Comment id found.'));
}
if (isset($match[1])) {
return array(
'id' => $match[1],
'subject' => $subject,
'comment' => $comment,
);
}
}