protected function AntispamCommentTest::testAnonymousComments in AntiSpam 7
Tests antispam functionality for anonymously posted comments.
File
- tests/
antispam.test, line 138 - Tests for antispam.module.
Class
- AntispamCommentTest
- Tests antispam functionality for comments.
Code
protected function testAnonymousComments() {
// Allow anonymous users to post comments.
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => FALSE,
));
// Post a comment with a name.
$edit = array(
'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this
->randomName(),
'subject' => $this
->randomName(),
'name' => $this
->randomName(),
);
$node = $this
->drupalCreateNode();
$this
->drupalGet('comment/reply/' . $node->nid);
$this
->drupalPost(NULL, $edit, t('Save'));
// Log in as an admin user and view the node.
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('node/' . $node->nid);
$this
->assertText($edit['name'], 'The submitted name of the anonymous user was found.');
$this
->drupalLogout();
// Post a comment without a name.
$edit = array(
'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this
->randomName(),
'subject' => $this
->randomName(),
);
$node = $this
->drupalCreateNode();
$this
->drupalGet('comment/reply/' . $node->nid);
$this
->drupalPost(NULL, $edit, t('Save'));
// Log in as an admin user and view the node.
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('node/' . $node->nid);
$this
->assertText(variable_get('anonymous', t('Anonymous')), 'The anonymous user name was found.');
}