function TriggerOtherTestCase::testActionsComment
Tests triggering on comment save.
File
-
modules/
trigger/ trigger.test, line 623
Class
- TriggerOtherTestCase
- Tests other triggers.
Code
function testActionsComment() {
// Assign an action to the comment save trigger.
$test_user = $this->drupalCreateUser(array(
'administer actions',
));
$this->drupalLogin($test_user);
$action_id = 'trigger_test_generic_action';
$hash = drupal_hash_base64($action_id);
$edit = array(
'aid' => $hash,
);
$this->drupalPost('admin/structure/trigger/comment', $edit, t('Assign'), array(), array(), 'trigger-comment-insert-assign-form');
// Set action variable to FALSE.
variable_set($action_id, FALSE);
// Create a node and add a comment to it.
$web_user = $this->drupalCreateUser(array(
'create article content',
'access content',
'skip comment approval',
'post comments',
));
$this->drupalLogin($web_user);
$node = $this->drupalCreateNode(array(
'type' => 'article',
'promote' => 1,
));
$edit = array();
$edit['subject'] = $this->randomName(10);
$edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = $this->randomName(10) . ' ' . $this->randomName(10);
$this->drupalGet('comment/reply/' . $node->nid);
$this->drupalPost(NULL, $edit, t('Save'));
// Verify that the action variable has been set.
$this->assertTrue(variable_get($action_id, FALSE), 'Check that creating a comment triggered the action.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.