function RadioactivityNodeTestCase::testActions_commentNoAutoApproval in Radioactivity 6
File
- plugins/
radioactivity_node.test, line 113
Class
Code
function testActions_commentNoAutoApproval() {
$this
->setCommentPreview(FALSE);
$node = $this
->drupalCreateNode(array(
'type' => 'story',
));
$admin = $this
->drupalCreateUser(array(
'access comments',
'post comments',
'administer comments',
));
$user = $this
->drupalCreateUser(array(
'access content',
'access comments',
'post comments',
));
$rid = -1;
// we need to remove manually permissions from role 'authenticated user'
// as it gets 'post comments without approval' which we specifically want not to have
foreach ($user->roles as $cand_rid => $rolename) {
if ($rolename == 'authenticated user') {
$rid = $cand_rid;
}
}
db_query("UPDATE {permission} SET perm='post comments' WHERE rid=%d", $rid);
$this
->drupalLogin($user);
$edit = array();
$edit['subject'] = 'subject';
$edit['comment'] = 'comment';
$this
->drupalPost('comment/reply/' . $node->nid, $edit, t('Save'));
$match = array();
// Get comment ID
preg_match('/#comment-([^"]+)/', $this
->getURL(), $match);
if (isset($match[1])) {
$cid = $match[1];
}
// note that drupalPost redirects back to node view page, so we get 11 energies
// from authenticated view, and another 100 from comment submit
$dbresult = db_query("SELECT energy FROM {radioactivity} WHERE decay_profile=1 AND class='node' AND id=%d", $node->nid);
$energy = db_result($dbresult);
$this
->assertEqual(111, $energy, t('Check energy after comment submit (unpublished)'));
$dbresult = db_query("SELECT * FROM {comments} ORDER BY cid DESC");
$comment = db_fetch_object($dbresult);
// publish the comment
$this
->drupalLogin($admin);
$edit = array();
$edit['comments[' . $cid . ']'] = 1;
$edit['operation'] = 'publish';
$this
->drupalPost('admin/content/comment/approval', $edit, t('Update'));
$dbresult = db_query("SELECT energy FROM {radioactivity} WHERE decay_profile=1 AND class='node' AND id=%d", $node->nid);
$energy = db_result($dbresult);
$this
->assertEqual(1111, $energy, t('Check energy after publish'));
}