function ForumAccessBaseTestCase::createFAForum in Forum Access 7
1 call to ForumAccessBaseTestCase::createFAForum()
File
- tests/
forum_access_test_base.php, line 633 - Base class with auxiliary functions for forum access module tests.
Class
- ForumAccessBaseTestCase
- Base test class for the Forum Access module.
Code
function createFAForum($id, $tag, $description, array $accesses) {
$edit = array(
'name' => "Forum {$id} {$tag}",
'description' => $description,
'parent[0]' => 0,
'weight' => '0',
);
$forum = (object) ($edit + array(
'tid' => 2,
));
$edit["forum_access[grants][checkboxes][view][1]"] = FALSE;
$edit["forum_access[grants][checkboxes][view][2]"] = FALSE;
$edit["forum_access[grants][checkboxes][create][2]"] = FALSE;
foreach (array(
$this->webmaster_rid,
$this->forum_admin_rid,
$this->edit_any_content_rid,
$this->edit_own_content_rid,
$this->create_content_rid,
$this->admin_rid,
$this->anon_rid,
$this->auth_rid,
) as $rid) {
foreach ($accesses as $access) {
$key = "{$access}-{$rid}";
if (array_search($key, array(
'update-3',
'delete-3',
)) === FALSE) {
$edit["forum_access[grants][checkboxes][{$access}][{$rid}]"] = TRUE;
}
}
}
$this
->drupalPost('admin/structure/forum/add/forum', $edit, t('Save'));
$this
->assertResponse(200, "'{$forum->name}' added.");
// Set moderator.
$acl_id = _forum_access_get_acl($forum->tid);
$this
->assertNotNull($acl_id);
acl_add_user($acl_id, $this->moderator->uid);
$this
->assertTrue(acl_has_user($acl_id, $this->moderator->uid), t('User %moderator is moderator.', array(
'%user' => $this->moderator->uid,
)));
// Show the result.
$this
->drupalGet("admin/structure/forum/edit/forum/{$forum->tid}");
$this
->assertResponse(200, "^^^ '{$forum->name}' exists, with these settings.");
$this
->drupalGet('forum');
$this
->assertResponse(200, 'Forum Overview');
return $forum;
}